Workaround for intermittent crash on image shutdown (VM issue #128)
Workaround for intermittent crash on image shutdown (VM issue #128)

The VM quit primitive works by throwing a Win32 exception that is trapped
in the main entry point function of the VM. This is done to unwind the
stack cleanly running any clean-up blocks on the way (mainly important
when running in-proc). Or at least that is the theory.
When Dolphin was originally written this worked fine because Windows
allowed exceptions to be thrown over user->kernel->user mode transitions
and be caught in the user mode code on the other side. Since Windows 7
(I think) the OS hasn't allowed this, so if Dolphin is (for example)
inside a callback to process a windows message, then the exit attempt
fails causing another unhandled exception.
This workaround defers the exit attempt to be processed by the main UI
process when the input queue is empty. There are some cases where this will
still fail, but it significantly reduces the likelihood.

dolphinsmalltalk/Dolphin,dolphinsmalltalk/Dolphin,shoshanatech/Dolphin,jgfoster/Dolphin,dolphinsmalltalk/Dolphin,shoshanatech/Dolphin,blairmcg/Dolphin,shoshanatech/Dolphin,objectarts/Dolphin,dolphinsmalltalk/Dolphin,jgfoster/Dolphin,blairmcg/Dolphin,shoshanatech/Dolphin,blairmcg/Dolphin,objectarts/Dolphin,jgfoster/Dolphin,jgfoster/Dolphin,blairmcg/Dolphin