Stop a script. Just stop it
How can I stop a mathematica script?
Abort does not stop the script, just jump over a number of lines and proceed with next lines of calculations.
Also, killing the kernel seems not good idea. All I want is C++ exit(0); or Java's System.exit(0);.
(* 10000 lines of calculations *) If[a==5,Print["Calculation gives an unacceptable result. I stop execution here"];Abort] (* 10000 lines of calculations *)
The script invoked from Mathematica GUI with Shift+Enter.
Solution as stated by thorimur
Catch[ (* COMPLETE SCRIPT *) (* Lots of calculations *) Throw["Calculation must be stopped"]; Print["Never printed"]; (* Lots of calculations *) ]