There will be times when you want to stop Mathematica in the middle of a computation. You may have asked Mathematica to do something that you did not intend or that is taking too much time. Mathematica provides several convenient ways to stop computations, including menu items and commands that you can use in your programs.
The menu items to stop or pause computations can be accessed from the Evaluation menu:
This Do loop sequentially prints each integer from 1 to 1000, pausing for half a second at each step. It takes over ten minutes to finish:
Mathematica then outputs $Aborted:
If Abort Evaluation does not succeed in stopping the computation, you can do so by quitting the active kernel.
This stops all computations in the selected kernel. However, by quitting the kernel you will lose the results from your session, including definitions of variables and functions and output from computations. You should therefore use this with caution.
You must have a kernel running to perform computations. If you quit your only running kernel, you must start one again. To do this, simply evaluate any expression in a notebook, or select a kernel to start in the Evaluation ► Start Kernel menu.
Mathematica lets you momentarily pause a computation instead of completely stopping it. To do this, select the cell bracket of the running computation and then select Interrupt Evaluation from the Evaluation menu:
Mathematica also provides an alternative to using Interrupt Evaluation to enter a kernel subsession. With a computation running, select the cell bracket of the expression you want to evaluate and then select Evaluation ► Evaluate in Subsession.
To remove a cell from this evaluation queue, first select its bracket. Here, the queued cell is selected while the Do loop continues to run:
You can also stop a computation by using Abort as part of a Mathematica expression.