title: remote ssh command not exiting
body: <p>I have a restart script written in ruby</p>
  
  <pre><code>#!/usr/bin/env ruby
  
  require "#{DIR}/etc/control_helper"
  
  
  ###### MAIN program ################
  case action
      when 'start'
           .....
  
      when 'stop'
            .....
      when 'restart'
          kill_the_old_process_if_needed(PORT_NUM, APP_NAME, APP_FILE_NAME)
  
          new_pid = start_a_new_process!(ENVIRONMENT, PORT_NUM, APP_FILE_NAME)
  #here there is an **exit(0)**
          check_for_success_in_starting_new_process!(hostname, new_pid) 
  
  end
  </code></pre>
  
  <p>running the code from the local machine works:</p>
  
  <pre><code>ruby etc/control_app.rb restart production
  </code></pre>
  
  <p>but running it from remote ssh (jenkins machine, after code change)
  doesn't exit . </p>
  
  <pre><code>gcloud compute ssh remote_server --zone us-central1-a --command "cd /path/to/app; ruby etc/control_app.rb restart production"
  </code></pre>
  
  <ol>
  <li><p>if i edit the script and put <code>exit(0)</code> at first then it exits. </p></li>
  <li><p>I know it get to the exit(0) because I have placed a print directly above it.</p></li>
  </ol>