a deterministic way to wait for file watching to finish cleanup