Cleanup of OnExit code.