title: exiting shell script with background processes
body: <p>I need somehow to exit my script.sh (with return code - would be the best) which runs some other commands and other scripts in the background.</p>
  
  <p>I've tried to run commands via</p>
  
  <pre><code>nohup myInScript.sh &amp;
  </code></pre>
  
  <p>also I've tried to use at the end of script.sh</p>
  
  <pre><code>disown -a[r]
  </code></pre>
  
  <p>and also I've tried to kill it</p>
  
  <pre><code>kill $$ 
  </code></pre>
  
  <p>but the script just hangs after last command and won't quit.
  How to force it to exit after running its commands?
  please help.</p>
  
  <p>edit: To be more specific, I'm running the script remotely via ssh on the other machine.</p>