Try to subclass the QCoreApplication and reimplement the quit() signal with inserting a debug print in.
You will see that the quit function is called immediately before your second print in the "run" slot, provided you are using DirectConnection
.
Also, worth nothing that quit() is slightly different to the GNU C exit() as per documentation:
Note that unlike the C library function of the same name, this function does return to the caller -- it is event processing that stops.
This means quit() dos not mean that application quits right away without terminating gracefully in the middle of your method execution.