When quiting while closing window, it will leave the window delegate out of the autorelease pool and crash. Fixes #881.