QWidget is not your application and does not have an "exit status". A class derived from QCoreApplication provides an exit status through the return value of QCoreApplication::exec(). It has a QCoreApplication::aboutToQuit() signal that is issued on a normal exit.

An application usually crashes due to some abnormal occurrence that your code does not trap. This is often the result of a signal. You can install a signal handler to trap the signal, but that doesn't mean you can do anything about it other than make a more graceful exit from your program.

Why don't you find and fix the cause of your program crashes instead? Good programs never crash, because the programmers who write them take care to write code that checks for errors instead of just letting them happen.