Initial import of atexit routine