When a script terminates, View.endProcess() is invoked automatically for all View objects that require it. So it is actually much better to let the runtime decide how and when to call View.endProcess() upon a script termination caused by an uncatched exception.
However, View.endProcess() should be called by a script if it handles an exception in a situation like:
try
{
view.beginProcess();
processTheViewHere();
view.endProcess();
}
catch ( x )
{
view.endProcess();
handleTheExceptionHere();
}
or even:
let beingProcessed = null;
try
{
doSomethingThatCanThrowExceptions();
view.beginProcess();
beingProcessed = view;
processTheViewHere();
view.endProcess();
beingProcessed = null;
doSomethingElseThatCanThrowExceptions();
}
catch ( x )
{
if ( beingProcessed )
{
beingProcessed.endProcess();
beingProcessed = null;
}
handleTheExceptionHere();
}