The two following methods in the ScriptContext will abort the script execution:
The ScriptContext.abort(String) method aborts the current script. The Scripting engine will use the throwable exception to stop the execution
The ScriptContext.abort() method aborts the current script without a message. The Scripting engine will use the throwable exception to stop the execution, but no message will appear on the console
The abort method will abort the script execution. It can be listened by an Exception listener.
Aborting outside of the script
It is also possible to abort the script execution in external code using the scripting framework, by using one f the two following methods: