stat: avoid hang with race in stat thread exit and rusage update

Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/stat.c b/stat.c
index a5fd50b..3aae76d 100644
--- a/stat.c
+++ b/stat.c
@@ -1451,6 +1451,8 @@
 	}
 
 	for_each_td(td, i) {
+		if (td->runstate >= TD_EXITED)
+			continue;
 		if (td->rusage_sem) {
 			td->update_rusage = 1;
 			fio_mutex_down(td->rusage_sem);