How to | Stop a Computation
There will be times when you want to stop the Wolfram System in the middle of a computation. You may have asked the Wolfram System to do something that you did not intend or that is taking too much time. The Wolfram System 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:
To illustrate the stopping or pausing of computations, first set up a computation that takes some time to complete.
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:
To stop this computation, first select its cell bracket:
Then select Abort Evaluation from the Evaluation menu:
The Wolfram System then outputs $Aborted:
If Abort Evaluation does not succeed in stopping the computation, you can do so by quitting the active kernel.
Select the kernel name from the Evaluation ▶ Quit Kernel menu. This menu item is located at the bottom of the Evaluation menu. Here, Local is the name of 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.
Here, kernel Local is restarted:
By selecting the brackets of more than one input cell and pressing , the Wolfram System lets you send several cells to the kernel for evaluation.
The cells are evaluated one by one. The bracket of each cell queued for evaluation thickens, indicating it is currently being evaluated or is in the evaluation queue:
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:
Remove the selected cell from the evaluation queue by using Remove from Evaluation Queue from the Evaluation menu:
You can also stop a computation by using Abort as part of a Wolfram Language expression.
Stop the evaluation of a sequence of commands:
Define a function for doing fixed-point iteration that aborts if the value gets above a certain limit:
Here, an unstable iteration is aborted:
This is a stable iteration that approximates the golden ratio: