I have a complicated script (not just written by me) that gets called using
MathKernel -script script.m. Among others
script.m uses parallel subkernels and external calls through
OpenRead["!"<>cmd]. I sometimes encounter a situation where all lines until
Quit get run yet the task never completes. So something of the form
lotsOfCode ... Print["We arrived at Quit"]; Quit
"We arrived at Quit" will print but the task will never
lotsOfCode should be viewed as a black box. What could be preventing the script from terminating? How can I really Quit?
System: Linux, Mathematica 11.1 (and 12.1)
I am happy with a linux based solution so I'm thinking I should probably invoke something like
kill through something like
RunProcess in order to get Mathematica to kill itself. A cleaner Mathematica based solution that figures out what is preventing it from quiting would of course be nicer.
This question seems related though it is looking for a different type of solution.