Add on_exit event hook