"monitor"
.
// display name of work and amount. monitor.beginTask("test", 100); for(var i = 0; i < 100; i++){ // Delay time. sleep(100); // Notify progressed. monitor.worked(1); } monitor.done();
If you press the Cancel button during the execution of the script, script stop to force and, the execution of the script is forced to stop and all the work performed till then will be canceled automatically.
If a script is written wrongly and fall into infinite loop, you can safely terminate it.