Automatically running testStopTimer before closing the software

Is there any way that when closing the software a record of the work session hours appears automatically executing the testStopTimer command?