How to end any code currently being run by Node VM2
<p>I am running some sandboxed code in Node using <a href="https://www.npmjs.com/package/vm2" rel="nofollow noreferrer">vm2</a>.</p>
<p>The code being run will be mostly asynchronous. It is untrusted code, and can not be relied upon to conform in any way- hence why I'm using <code>vm2</code> to run it.</p>
<p>Does vm2 have a way of ending any code currently executing? The documentation is very limited. For example, if I were to have this code:</p>
<pre><code>var code = 'setInterval(function(){ console.log(&quot;tick&quot;); }, 1000);'
vm.run(code);
</code></pre>
<p>Is there any way I could run such the above, and halt it at some point in the future, without the controlling code having to know anything about the contents of <code>code</code>, and without <code>code</code> having to provide any specific features?</p>
<p>I cannot find a <code>vm.stop()</code> method or similar.</p>