Fix bug where close twice