make ParquetFileWriter throw IOException in invalid state case

and make sure to close the underlying stream in the end