Add before_stop hook