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