7b00f39140
Improves https://github.com/apple/containerization/pull/245. A potential deadlock risk was not proven. This PR moves the closing operation inside the lock to prevent leaking an unclosed handle in case of an error.