remove handler when closing