fix atexit when it is called from an atexit handler