Changed atexit call and function name
Changed atexit call position and supplied function name

A crash that occurs during the game may never hit the atexit(...) line
otherwise