Question: When I design adventures, I often come up with situations where the NPCs could realistically thwart the PCs quickly by sounding an alarm. This is especially common in science fiction settings, where the NPCs have access to surveillance cameras, radars, motion detectors, and other advanced technology. This makes stealthy missions difficult to pull off, because the PCs can be revealed in a matter of seconds if they make even a single mistake.

**How do I keep NPCs from just sounding the alarm right way, without suspending disbelief too much?**

Answer: 
"Step away from that alarm, rookie. We don't need the 5-0 kicking in the door and making everybody play nice. When you've been here as long as I have, you'll realize that a night like this is a night to have some fun. Why did I sign up to be a security guard if not to lay down some pain every once in a while? Let's go kick some ass!"
The very simple answer is: you don't.

Roleplaying is about making decisions that have consequences. As a Game Master, it's up to you to make those consequences interesting and fun, but that doesn't mean they should always be beneficial to the party or the characters that incur them.

If the players set off an alarm, then they will learn pretty quickly that they need to think smarter and prepare more for future encounters. As long as you give them options and allow for reasonable escape opportunities, ultimately the fate of the characters should be in *their* hands, not yours.