Fix for crash, from double calling of destructor when MainWindow went out of scope