Interrupting a process in a script

This example shows the functions for interrupting a process instance (the current process instance cannot be interrupted). The code interrupts the process without checking if the user running the script has special permissions. 

Namespaces:

using EleWise.ELMA.Security;
using EleWise.ELMA.Services;
using EleWise.ELMA.Workflow.Managers;

Script text:

Locator.GetServiceNotNull<SecurityService>().RunWithElevatedPrivilegies(() => WorkflowInstanceManager.Instance.Terminate(context.WorkflowInstance, "Reason"));
Creating a similar script with PublicAPI
Updated documentation on PublicAPI is available here.
The script given above works for PublicAPI versions 3.8 and higher
PublicAPI.Services.Security.RunWithElevatedPrivilegies(() => PublicAPI.Processes.WorkflowInstance.TerminateProcess(context.WorkflowInstance, "Reason"));