File close fixes

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index 17bdd26..a0a4b80 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -710,8 +710,10 @@
 	struct fio_file *f;
 	unsigned int i;
 
-	for_each_file(td, f, i)
-		td_io_close_file(td, f);
+	for_each_file(td, f, i) {
+		if (fio_file_open(f))
+			td_io_close_file(td, f);
+	}
 }
 
 void close_and_free_files(struct thread_data *td)