Python Execute Code Before Terminates

def cleanup():  
    ... clean up script ...

# on exit
atexit.register(cleanup)  

Konpat Preechakul

Read more posts by this author.