Use atexit instead