Hi. This is a very interesting question .
The main options probably are:
- Attach a timer ("boundary") to the task, and terminate the task when the timer "fires"
- Attach an event receiver ("boundary") to the task, and terminate the task when the event arrives ("fired" from a BPM process/service - also a service inside the implementation of the task... - or from an external system by queuing and UCAs)
- Use the rest api "move token" to move the token from the task to another task
- use the BPM server side JavaScript API TWTask.complete to programmatically "complete" the task