Personally, I avoid deus ex machina like the plague – if you have to use one, it means you failed to set up the universe and the plot properly. It’s like a whodunnit where there’s no actual way for the reader to identify the perpetrator before the climactic reveal: there’s no sense of closure for the reader.