move on_exit hook call

move the on_exit hook call to run after the pidfile unlinking