Fix bug that occurs if close/closeAll is called more than once