Wait for async threads before freeing/killing IO buffers

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/fio.c b/fio.c
index 8f8bb56..debcac5 100644
--- a/fio.c
+++ b/fio.c
@@ -1195,6 +1195,10 @@
 	if (td->error)
 		printf("fio: pid=%d, err=%d/%s\n", (int) td->pid, td->error,
 							td->verror);
+
+	if (td->o.verify_async)
+		verify_async_exit(td);
+
 	close_and_free_files(td);
 	close_ioengine(td);
 	cleanup_io_u(td);
@@ -1205,9 +1209,6 @@
 		td_verror(td, ret, "fio_cpuset_exit");
 	}
 
-	if (td->o.verify_async)
-		verify_async_exit(td);
-
 	/*
 	 * do this very late, it will log file closing as well
 	 */