Fix crash when the window is closed before the settings dialog.