In less interactive forms of art, the deus ex machina has an understandably poor reputation. Given a single or even a small number of similarly geared authors co-writing a plot, there is no excuse to have to fall back to a metaphysical (or quasi-metaphysical) outside force in times wherein characters are caught in a quagmire. If worst comes to worst, you scrap a chapter, rewind, and try again, avoiding the mistakes you made to get them there.
In roleplaying games, the stigma of the literary device remains… but it doesn’t have to, nor, in my opinion, should it. In fact, if anything, I’d say it’s a fallback a gamemaster should always be pointedly aware of and ready to use, in as much as the setting permits.
Outright retconning a portion of the plot in roleplaying games can and does happen, but sometimes characters simply cannot and will not bend to the whims of the players. An easily fixable example might be a notoriously stupid character being caught by the enemy – all right, you’ll roll back the session and fix that oversight. Unfortunately, you can spin this as far back as you want: Is something that someone said a few sessions ago coming to bite them in the ass? Is an old feud set up a few months ago finally blossoming into the plot and turning out to be more dangerous for the characters than anticipated?
The moment something can’t be fixed by tweaking character actions reasonably (or, if the players are willing, even beyond the point of ‘reasonably’, though I’d not advise this), you may well be forced to rely on lucky coincidence, fortunate circumstance, or even divine intervention.
Of course it’s nice and rewarding if the plot is carried solely by the efforts of player characters, but there’s nothing wrong with falling back to NPC or scenic help if something’s gone wrong.
I’m of the school of thought that a gamemaster should try to build their world in layers that let their crew survive Xanatos Gambit style: Always have a fallback plan that doesn’t depend on your players. There are greater forces at play, and if things work out the way they should, you can use them to fish the hapless characters out of an otherwise lethal situation.
Of course, it’s easier in some settings than in others. In a cyberpunk universe with a ‘trapped in virtual reality’ setting, you might have the artificial intelligence of the servers that watches the progress of trapped netizens. To these watchful eyes, some death and destruction may be all right – but the moment it looks like all of those precious subjects are threatened, there will be consequences: The whole gaggle of people will simply be transplated from the current virtual-world-gone-wrong into another. Presumably not without heavy losses, but that goes without saying.
A deus ex machina is the ace up your gamemaster sleeve. Make sure you have one, make sure it makes sense, and above all, make sure that you ensure one thing about it: Make your players shudder at the thought of it coming to use. Play it as a ‘get out by the skin of your teeth’ or ‘with heavy losses’ rather than a ‘get out of jail free’ card, and atmosphere won’t suffer even a notch.