Add _on_exit() at the end of main.