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.