renamed moon_finalizer to moon_atexit; implemented new moon_finalizer function