Using QFileDialog::getOpenFileName(...) anywhere in my mainWindow prevents the application from closing when the mainWindow is ultimately closed; it continues to run in the background until I stop it through task manager or, if running in Qt Creator, click the red square.

QColorDialog and QMessageBox do not cause this problem, so it is not merely caused by opening a new window.

I have tried connecting both the application's lastWindowClosed() signal and the mainWindow's destroyed() signal to the application's quit() slot, to no effect.

I defined a destructor for my mainWindow and verified that the code there executes when the user clicks the red X in the corner. I even put the command this->destroy() in that destructor, again to no effect.

I would appreciate advice if anyone has encountered this or a similar issue.