Search notes:

Python standard library: atexit

atexit provides the two functions:
The registered functions are not called when
import atexit
import time
from datetime import datetime

def the_end():
    print('the end has come.')

atexit.register(the_end)

for i in range(10):
    time.sleep(1)
    print( 10.0 / (i-5) )

See also

standard library

Index