Fix closing crash with Qt5