Changed to atexit