In ancient Greek theater, a crane (mekhane) was sometimes used to lower an actor playing a god onstage to get the protagonist out of a pickle. Or a machine was used to push the god up through a trap door. This gave rise (sic) to the phrase deus ex machina—God from the Machine.
The phrase deus ex machina (DEM) has been extended to refer to any resolution to a story which does not pay due regard to the story’s internal logic and is so unlikely it challenges suspension of disbelief, and presumably allows the author to end it in the way he or she wanted.
DEMs are still prevalent as a literary device. Last-minute rescues result from the sudden introduction of a new event, object or character. Most Harry Potter books/movies end with a DEM. Other examples include the giant eagles that save Frodo and Sam on the burning slopes of Mount Doom and Dorothy’s ruby sandals at the end of The Wizard of Oz.
Do DEMs happen in real life? Does God serendipitously intervene to save the day?
Not nearly as often as in the movies. While modern audiences demand happy endings, God seldom short-circuits cause and effect when it comes to our choices and circumstances. Instead he gives us the grace to persevere through adversity and the hope of a future where everything will be put to rights.
Miracles are unusual.
Grace is ubiquitous.
Hope is essential.