Fix race at exit.