clean up onExit function