The teleport spell passes the %zonetype variable ("town" or "dungeon") and you can clearly see it being parsed by GetNearestZone(). Indeed, there is even a third argument you can pass, "freeforall", though I don't know what that does.
Freeforall is a type of zone

Example: Warriors temple in my mod is a freeforall zone that allows anyone to be able to harm anyone without use of the targeting system or mimic.