Correct way to close the popup