I think that the inside of the clock tower is not a part of Termina. It's between worlds. In the beginning of the game, Link travels from Hyrule to Termina. He leaves Hyrule through the hollow tree. He enters Termina when he steps outside of the clock tower. That's when the three days start. That's the moment he gets sent back to when he plays the Song of Time. That's when he starts interacting with the Terminians. And you never see citizens of Clock Town entering the tower.
So between leaving Hyrule and arriving in Termina, Link is in some kind of Limbo. The laws of nature are weird here. Hylians can be changed into Dekus (notice that Skull Kid never tries this bit again once both are in Termina). Organs can appear out of nowhere. And time moves different here as well. After the first three days, you jump back to the first morning, and yet the HMS knows that time has passed.
So if the HMS stays in the tower (which isn't really the inside of the tower of Clock Town, but a magical Limbo), it stands to reason that the Moon destroying Clock Town couldn't harm him, just like it couldn't harm Zelda or Impa, who are back in Hyrule. That's why the HMS never leaves the tower.