Fix race in cleanupthread

4 jobs for master in 8 minutes and 44 seconds (queued for 1 second)