What you cuold do is set up so every door has a second door behind it controlled by a lever that is always open, then if a flood happens, pull the lever and close the doors.
It's kinda like my excessive, over the top defense of my current fort:
On the surface I have a tower that EVERYTHING MUST pass through in order to get in to my fort, that has 3 bridges in it - one that can block off the main entrance to the fort and two that open diretly into the tower so that if I get sieged, I close the tower AND the fort off, then when my military is ready I open the tower and charge out.
If the invaders gain access to the main entrance of the fort, there is another double set of bridges in a trapped hallway as a backup that can block off that walkway.
If the invaders gain access to the tower there is another lever that will retract the ONLY bridge connecting the tower to the fort, trapping the invaders inside the tower.
If the invaders get past the backups, my actual fort is on the OPPOSITE side of a chasm, retract that bridge and there is no way for them to get across, I an rebuild my army and regroup before striking back.
In the event of a total containment failure, there is an emergency switch that is only accesible from the fort side of the chasm, past a trapped hallway and INSIDE the chasm itself in a small chamber that will, upon being pulled, initiate a total lockdown of the fortress and tower. That is, EVERY door that isnt vital to blocking miasma and ALL the bridges are linked to this lever, when pulled it will completely seal off the entire fort and then I can initiate recovery of personell and, if viable taking back the fortress.
However, if it is deemed that the fortress is unrecoverable, there is also a backup that will be used only as a last resort. There is one final lever that is linked to a VERY large resevoir of magma, with pipes linked to every single room in the fortress. If this lever is pulled, the entire fort, other than the panic room described below will be flooded completely with magma, killing everyone and destroying all plans of world domination trade goods. Yup, just loads of trade goods. Unfortunately, this lever happens to be at the BOTTOM of the chasm, and when pulled will drop the chamber it's in into the pit.
The panic room is set up as protection against the final resort. Inside it holds a couple of picks, a food stockpile and a load of random other things like armour and weapons so that if the fortress is lost the survivors will be able to continue on and perhaps, if the magma cools or is otherwise removed, they can repopulate and continue on.
At the moment I'm working on drainage lever for the panic room that will be able to drain out the magma, that way if the fort is lost I can still recover it eventually, although at a substantial loss of equipment.
tl;dr = I go WAY over the top with protecting my fortress. WAY WAY over the top.
Oh, wow, that was quit off topic. anyways...