Two possible places:
1. SIGTERM signal handler if on unix
2. QApplication subclass destructor.

Remember that your app gets killed if you close the console window containing it.

BTW. Why are you spawning a separate thread? You don't need it...