Repair segfault at closing the MainWindow.