title: How to stop execution after changing window.location?
body: <p>Say I have some mobile check at the very top of my script:</p>
  
  <pre><code>if (isMobile) {
      window.location.href = '/m/' + window.location.pathname + window.location.search;
  }
  </code></pre>
  
  <p>And I also have some metrics down the code (or <em>even in some other module that is loaded asynchronously</em>) that are being sent to my metrics server.</p>
  
  <p>My question is: how can I stop execution of everything that goes below my <code>window.location</code> change? Or even better, how to stop the whole javascript engine so that it doesn't execute any other asynchronously loaded modules?</p>
  
  <p>I know that I can do mobile proxying in many different ways, but in this task my mobile redirect must be run on the client side, it is a given.</p>