Add after_terminate hook.