Ensuring that close cleanup is done