If application doesn't have any windows and it receives WM_QUIT message, it just returns immediately from exec(). The WM_QUIT message cannot be intercepted with anything as it is handled before native event filter and just causes the application to return from exec(). There is aboutToQuit signal, which was also suggested in
QTBUG-16236 as alternative way, but that is not triggered if the application doesn't have any windows.
Steps to reproduce
- Start windowless app
- End it via task manager
- Note aboutToQuit is not emitted
- QCoreApplicationPrivate::execCleanup() src\corelib\kernel\qcoreapplication.cpp:1389
- QEventDispatcherWin32::processEvents() at src\corelib\kernel\qeventdispatcher_win.cpp:595