Fixed a bug where the main window was being deleted.