When defining a task with LocalSubmit, a new subkernel is created. When you remove the task after the task is done, the task is removed but the subkernel remains open.

CloseKernals[] doesn't do anything, and $KernelCount also returns 0. The only way I could terminate the subkernal is by killing the process of that subkernel in OS process manager (e.g., Task Manager on Windows and htop in Linux.)

How can I neatly terminate the subkernel within Mathematica, without having to find its PID and force-kill it on OS process manager?

  • 1
    $\begingroup$ LocalSubmit[Pause[10] ; Quit[], HandlerFunctions->Association["TaskFinished"->0],HandlerFunctionsKeys->"EvaluationResult"], staff after code is to suppress dialog window popup $\endgroup$
    – I.M.
    Dec 20 '21 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.