How to run a Python callback when Blender exits?
While we could support this via bpy.app.handlers, we decieded not to add this since Python already supports exit callbacks, so you can use these (outside of Blender too - for any Python script).

See Python's atexit module.

Simple example use:

def goodbye(name, adjective):
    print("Goodbye, %s, it was %s to meet you." % (name, adjective))

import atexit
atexit.register(goodbye, "Suzanne", "nice")