python onexit

Was looking for python’s equivalent to onexit and found atexit:

1
2
import atexit
atexit.register(function_that_will_be_called_before_this_program_exits)