This is subtle; we don't want to leak resources when closing fails.