You should also call this function right after you call `/root/spark/bin/stop-all.sh` at the beginning of `run_shark_benchmark(opts)`. This will cover the case where the cluster is still shutting down a previous query when the script is called.