avoid close more than once