When developing functionalities with several parallel kernels, when a bug happens, I often have to manually close all parallel kernels (using the Task Manager in Windows) in order to start again from a clean state.

Is there any way to automate this task ?


2 Answers 2


In Windows you can create a .cmd file with the following lines in it:

tskill mathematica
tskill wolframkernel
tskill mathkernel

Executing it will make sure that all Mathematica processes are closed.

  • 2
    $\begingroup$ This also closes the front end and therefore one will lose all changes made within a notebook, doesn't it? $\endgroup$
    – Karsten7
    Jun 15, 2016 at 15:46
  • $\begingroup$ Indeed, in my use cases this is what I want as well, this can be adapted though. $\endgroup$
    – faysou
    Jun 15, 2016 at 17:22
  • 1
    $\begingroup$ I am confused, as @Karsten7 says, this doesn't seem to answer the question. But also, in my experience killing the frontend in Windows also kills any kernels running - is this not the case? $\endgroup$
    – Jason B.
    Jun 16, 2016 at 2:12
  • $\begingroup$ @Jason With older versions I encountered situations when killing the FrontEnd didn't kill the Kernel. $\endgroup$ Jun 16, 2016 at 10:54
  • $\begingroup$ When the main kernel is killed, parallel ones are not killed. $\endgroup$
    – faysou
    Jun 16, 2016 at 18:56

You may us the Parallel Kernel Status tool or may be able to use CloseKernels.

Parallel Kernel Status

Launch the tool from the Evaluation | Parallel Kernel Status menu.

enter image description here

If the kernels are already running then you will see them listed. There is a Launch All button if none are running. You can either close individual kernels or close them all.


If you configure another kernel from the menu Evaluation | Kernel Configuration Options then you can use this kernel to kill the parallel kernels. Before you execute the parallel notebook open a new notebook, start this kernel (Evaluation | Start Kernel), and set the new notebook's kernel to this (Evaluation | Notebook's Kernel). Since this notebook is on a different kernel than the parallel running notebook then you will be able to execute commands to it. Once your parallel running notebook is in trouble then in the new notebook execute the following.

Show all parallel kernels.

(* {"KernelObject"[17, "local"], "KernelObject"[18, "local"], 
    "KernelObject"[19, "local"], "KernelObject"[20, "local"]} *)

Close all parallel kernels.

(* {"KernelObject"[17, "local", "<defunct>"], 
    "KernelObject"[18, "local", "<defunct>"], 
    "KernelObject"[19, "local", "<defunct>"], 
    "KernelObject"[20, "local", "<defunct>"]} *)

(* {} *)

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.