Add close function to the close button in the dialog