Fix leaking threads when pruning the pool