Hopefully fix race between thread finishing and cleanup being run (#2100).