The origins of the phrase come from Greek drama. They would set up this horrible story line that could never possibly be repaired, and then they would literally lower a God, typically Zeus, in a cage-like machine/contraption. God would talk for a few minutes, and everything would be all better. Poof.
Although the scanning machine is pretty amusing...
Deus ex Machina
Although the scanning machine is pretty amusing...