add exit hook