Don't crash if we get into a weird state
Make sure we always quit when the application window is destroyed.
BUG: 385637