Wait for processes to finish in run-command-on-all.sh