Close the file on Write error too.