`close()` call should be in a `finally` section to avoid leaking stuff if there's an unexpected exception. Same for the rest of situations where `close()` is called.