Fixed main window closing bug.