Stop timer and run command history automatically

Is there a way to automatically stop the timer when closing Rhino and run the history command to save the entire work session?