Fixed stats printing before threads exit.