phantom.exit() never prevented code from being run it simply hid many of the side effects. You can test this out by running this code on 1.6:
phantom.exit();
phantom.injectJs('hey!')
The above causes a segfault because the code made mistakes in some of its side effect hiding logic. I fixed the above issue with this pull request
https://github.com/ariya/phantomjs/pull/302/. Unfortunately this pull request being perhaps a bit too ambitious got rid of a bunch of this logic and simply embraced the fact that we don't run prevent code from running after phantom.exit().
I've made a less ambitious change that prevents the segfault above as well as preserving the side effect hiding logic of before:
I've been looking a lot on how to actually prevent code from running after phantom.exit and it looks really difficult. The problem is that all the code we use to run js is an all or nothing kind of thing. For instance QWebFrame::evaluateJavaScript. You can't tell it to return from the call early, you can only wait until its done evaluating. I've thought of a number of solutions but none of them are totally ideal.
1. Use the c libraries exit to exit immediately. This is not awesome because we don't allow qt to do any sort of cleanup, and it limits how phantom can do its own cleanup.
2. Use setjmp/longjmp. This is awful for readabililty, but also we because we assume too much about the internal details evaluateJavaScript.If we just prematurely exit the call we don't let it do any sort of cleanup that it might need to do.
3. Implement phantom::exit as a thrown exception. This is probably my favorite solution but it might break existing scripts that have generic exception handlers.
We may also just say that this is a wontfix considering if we can remove all the sideeffects what does it matter if "var a = 3;" will be evaluated.