You might have heard of deus ex machina endings somewhere before - perhaps in reference to novel writing, more likely to movies or plays. But let's start by being totally clear about what the phrase means.
Here is the Oxford English Dictionary definition...
"Deus ex Machina, noun. An unexpected power or event saving a seemingly hopeless situation, especially as a contrived plot device in a play or novel."
The literal translation is "god from the machinery," and it derives from Ancient Greek theater.
The characters in the play would get themselves into a terrible mess (or a "seemingly hopeless situation" as the dictionary puts it) - so much so that the only way to sort out the mess was for the gods (or actors playing the gods) to emerge from the "machinery" of the stage and put the world to right again with their divine powers.
For our own plotting purposes, a "D.E.M." ending means a contrived or awkward or unbelievable ending, one which fails to flow naturally and logically from the events which preceded it in the novel.
Imagine a detective in a good old-fashioned Whodunnit. We'll call him Smith.
Now, we know that Smith will unmask the murderer by the end of the novel (because that's what happens in crime fiction). But for this unmasking to be satisfying to the reader, the name of the guilty person or persons must come to Smith as a result of his own skills and efforts.
Smith spends the bulk of the novel searching for clues, interviewing suspects, piecing together the evidence - in short, doing all the usual things a detective does in a crime novel.
Sure, he makes mistakes as he goes (all detectives do), and his initial thoughts and theories are proved wrong, but the reader has faith that his skills of detection will eventually lead him to the truth.
And eventually Smith would have discovered the identity of the murderer - if his creator had been any good at plotting novels.
Unfortunately, though, the writer calls in the gods and settles on a contrived ending instead.
Smith, you see, has reached a "seemingly hopeless situation"...
The murderer is arrested, Smith is patted on the back, and everyone is happy - everyone except for the novel's unsatisfied readers, of course.
Why are they left unsatisfied?
Because the crime was solved through Smith just happening to be in the right place at the right time, totally by chance.
It was solved by forces outside of the detective's control (by the Ancient Greek god of "luck", if you like), and not as a result of his own skills and efforts. The difference is critical.
If you want to keep your readers satisfied in your own novel writing pursuits (and I'm guessing you probably will), avoid a deus ex machina ending at all costs.
Keep the "gods" out of it and leave it to the mortals in the novel to sort out their own problems.
I had a follow-up question on this from one of my readers...
"In my story the main character ends up a quadriplegic, but with the aid of stem cells and lots of physio she walks again. Does that constitute what you call a contrived ending?"
The simple answer is that it could be a contrived ending. It all depends on how you handle it.
A contrived ending in a novel is one which arrives out of the blue and seems too convenient to be believable. It is one which fails to flow naturally and logically from the events that came before it.
In your own story, did you mention the possibility of a stem cell cure throughout the novel? Or did you suddenly spring it on the readers right at the end?
In the first instance, the ending would certainly have a touch of the deus ex machina about it. In the second instance, it wouldn't.
However a novel ends, it is important to lay the groundwork for it, or foreshadow it, earlier in the novel. How? By planting little "signposts" along the way that this is the direction in which things are heading.
Be careful, though. While it is important to prepare readers for the ending (so that it strikes them as believable), you don't want to make the end obvious. So make the signposts subtle. And also plant some other, misleading signposts which will lead the audience to expect an ending which never actually occurs.
Here are a few thoughts on how you might avoid a contrived ending in your own book:
Now, I might be completely off track with these suggestions. Without knowing the details of your novel, it is impossible to know. Hopefully, though, I have told you enough about deus ex machina endings in general for you to be able to figure out the specifics for yourself!