Wait for the thread pool before deleting the caches