title: phantom.exit(-1) doesn't work when called from another function
body: <p>I'm using PhantomJS to run JavaScript. There's a function <code>phantom.exit()</code> that accepts exit code as 1st argument.</p>
  
  <p>Here's how it works...</p>
  
  <pre><code>var page = require("webpage").create(),
      $ = require("jquery")
  
  page.open("http://127.0.0.1:8081/", function (status) {
      var title = page.evaluate(function() {
          return $("title").text()
      })
      phantom.exit(-1)
  })
  </code></pre>
  
  <p>Returned exit code is -1 or 255 as expected.</p>
  
  <p>My problem is that I need to exit script when my function is called. My function contains <code>phantom.exit(-1)</code>.</p>
  
  <pre><code>var page = require("webpage").create(),
      $ = require("jquery")
  
  function foo() {
      phantom.exit(-1)
  }
  
  page.open("http://127.0.0.1:8081/", function (status) {
      var title = page.evaluate(function() {
          return $("title").text()
      })
      foo()
      phantom.exit()
  })
  </code></pre>
  
  <p>Problem is that <code>phantom.exit(-1)</code> that's in <code>foo()</code> function is not called and exit code is 0.</p>
  
  <p>There's a workaround to check for return value in my function and call <code>phantom.exit()</code> manually, but it's not as I want it... Any help is much appreciated!</p>