If we want to refactor this part, putting the close function into another helper would be more reasonable IMO. (but I have no idea about the naming for new helper...)