Terminate google cloud compute engine instance with shell/bash script
<p>I am using google cloud compute engine for some computational intense tasks (32 parallel processes). My tasks sometimes finished in mid night, and I am wondering is there a way to stop the instance once all my processes stop? I prefer to make a shell script to monitor all my processes and stop the instance when everything is finished.</p>

<p><code>halt</code> or <code>shutdown</code> or <code>poweroff</code> does not works for me, as my command only submit jobs. The command finished immediately while all processes (computing tasks) kept running on the backend. If I put <code>halt</code> or <code>shutdown</code> at the end of my command line, the instance simply shut down as I entered the command</p>