How can I prevent my players from teleporting out to escape any dungeon?

My high-level party now has 2 casters able to cast teleport. They can now run into any dungeon and just escape freely when things get dangerous. Forbiddance does not prevent you from teleporting out and Antimagic Field is a 10ft radius spell that requires concentration.

How can I prevent my players from pulling off this cheesy strategy against smart opponents who have witnessed this strategy multiple times and can plan beforehand?

So far, I’ve only come up with Darkness spells (to prevent players from seeing each other to teleport) or Counterspells at the time of cast. Both are fairly unsatisfactory solutions, PCs can just run into another room, or behind a pillar, and teleport there. Is there any RaW way to protect the entire dungeon?