MainWindow on closing bug fixed