DM says so is fine, as long as it is well in advance. Not so good if they plan their escape well in advance with teleport as an essential part and you spring it on them when they cast the spell.
"Sorry guys, the teleport didn't work. There must be some sort of teleport protection or something. Looks like a TPK for you."
So PCs should have perfect knowledge of the world around them? Sometimes you are surprised. Better have a back up plan.