If a hero is occupying a town, and wishes to teleport out of the town to any friendly tile, the spell will not function. Every friendly tile will be seen as "red", ie the spell cannot be used to that location.
I see no reason why any different logic should be applied in a town compared to in the field, and therefore I assume that this is a bug. If not, the spell should state so in description.