title: Best way to stop load script execution in Ruby on Rails's IRB
body: <p>Looking for the best way to exit a loaded script in Ruby on Rails's IRB. Kernel.exit &amp; Kernel.abort will pop you out of the IRB session altogether. Ideally, this would happen on some conditional criteria.</p>
  
  <p>My script/my_script.rb:</p>
  
  <pre><code>puts "My Script is running!"
  # if some criteria, stop execution of this script without stoping IRB
  puts "This will never happen"
  </code></pre>
  
  <p>Ideal results:</p>
  
  <pre><code>$ rails console
  irb(main):001:0&gt; load 'script/my_script.rb'
  My Script is running!
  irb(main):002:0&gt;
  </code></pre>