Fix  app exit: use gui->deleteLater().
Also fixed a crash in the file dialog on windows