Close stream in `ArrowWriter.finalize` before inference error
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/datasets/pr_5309). All of your documentation changes will be reflected on that endpoint.
Ensure the file stream is closed in `ArrowWriter.finalize` before raising the `SchemaInferenceError` to avoid the `PermissionError` on Windows in `incomplete_dir`'s `shutil.rmtree`.