title: How to kill a javascript function?
body: <p>sample code:</p>
  
  <pre><code>var isExecutionOver = false,
      myFunction = function() {
        // does some asynchronous stuff and sets isExecutionOver to true
        // when the asynchronous job is over.
      };
  
  myFunction();
  
  // Kill myFunction if it takes more than 3 seconds
  setTimeout(function() {
    if(!isExecutionOver) {
      // How do I kill myFunction?
    }
  }, 3*1000);
  </code></pre>
  
  <p>In the above snippet I am trying to kill (or in other words, stop execution of) <code>myFunction</code> if it is not able to do its job in given time (3 seconds in this case).</p>
  
  <p>PS: Kindly assume that I do not have control over myFunction definition. The only place where I can work is inside <code>setTimeout</code>.</p>