# A WolframKernel (with PID) is created by a LocalSubmit. After the LocalSubmit finishes its job, the kernel remains. How to kill it within Mathematica?

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?

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