// obtain statement lock
StatementAgentInstanceLock lock = agentInstanceContext.getEpStatementAgentInstanceHandle().getStatementAgentInstanceLock();
lock.acquireWriteLock(null);
try {
if (finalView instanceof OutputProcessViewTerminable && !isStatementStop) {
OutputProcessViewTerminable terminable = (OutputProcessViewTerminable) finalView;
terminable.terminated();
}
stopSafe(stopCallback, agentInstanceContext.getStatementContext());
if (servicesContext.getSchedulableAgentInstanceDirectory() != null) {