(IANAL.) Employment agreements generally are not enforceable when they conflict with the law, AFAIK. The security guard might be required to never open the door, but when a police officer or court gives them a lawful order to open it, they open it or go to jail. I doubt they could be fired for opening it in that circumstance; your employer cannot require to you violate the law.
Another way of looking at it: You can write whatever you want on paper and sign it, but that doesn't make it enforceable. You could sign a document that makes you a slave or puts up your children as collateral for your ISP bill, but those agreements would be scrap paper (or evidence for the prosecutor).