title: Terminate ros2 nodes in bash
body: <p>I currently have a bash script which launches my ros2 nodes.This works perfectly fine. I now tried to start the script as a background task and write the output into a file. When doing so, I am unable to terminate the nodes at a later point. Previously I terminated it by hitting <code>Ctrl + C</code> in the terminal and all nodes stopped. I tried to do same by saving the PID when starting the script and then killing it afterwards, however the nodes keep running.</p>
  <p>Is there any possibility to stop all nodes started by the script? Stopping all ros2 nodes is not possible because I launch multiple in parallel.</p>
  <h3>Start</h3>
  <pre class="lang-sh prettyprint-override"><code>&quot;./${SCRIPTFILE}&quot; &gt; $LOGFILE  &amp; 
  echo $! &gt; $PIDFILE
  </code></pre>
  <h3>Stop</h3>
  <pre class="lang-sh prettyprint-override"><code>kill -TERM $(cat $PIDFILE) 2&gt; /dev/null
  </code></pre>