Adding before close callback