I think most writers would agree Deus Ex Machina's best used at the beginning or middle of a tale, where it can be used to bring an unexpected element into the story in a very dramatic fashion. However while putting it in at the end is more tricky, it's still a useful tool to keep around.
I'm not sure if a foreshadowed event counts, but if so a good amount of foreshadow can turn Deus Ex into a huge payoff. For example Issola when the main character gets, via very convoluted means, the item he needs to survive the fight he's in (Godslayer) it doesn't seem terrible, because the author has been foreshadowing this event for at least eight books. The moment he puts it all together you go "Oh...." It turns into a huge payoff for the reader.
If your story is emphasizing how powerless the main character is, or how randomly kind and cruel the universe can be, then having an ending completely unrelated to the main characters actions is perfectly fitting. It's the perfect capstone.
Monty Python and the Holy Grail similarly has a great Deus Ex. When your comedy is about semi random slapstick jokes you can get away with it. Everything can be forgiven if it's funny.
And lastly Deus Ex can work if it turns out to be not that contrived after all. No one expects the police to kick in the door during your hero's final confrontation with the time traveling Sorcerer, but you know, maybe the neighbors called 911 when you started shooting his zombie minions. Or to use a real example, in one of the Birds of Prey books, Black Canary got herself in a very tough situation that she couldn't get out of. So Oracle called in Superman who took all of three panels to KO the guy. Because they can do that, even though the genre conventions lead the reader to forget that.
So yeah, an important tool, but one that needs to be used deliberately.