Skip to main content

Terminate an Activity

View Markdown

Terminate forcefully closes an Activity Execution with no opportunity for your code to clean up.

When to Terminate

  • A Standalone Activity is stuck or misbehaving and you need it closed now, whether or not it Heartbeats.
  • A Request Cancel was already sent and the Activity didn't honor it.

Terminate isn't available for Workflow Activities, because the Workflow owns the execution's lifetime.

What happens when you Terminate an Activity

The Activity Execution closes immediately and discards its progress. Activity code can't see or respond to a termination, so no cleanup runs and no Cancellation error is raised. Unlike Request Cancel, this doesn't depend on the Activity Heartbeating, and it can't be declined by your code.

The Execution and its result remain visible to temporal activity describe and temporal activity list for the Namespace Retention Period. To remove the record sooner, use Delete.

CLI usage

temporal activity terminate \
--activity-id my-activity \
--reason "Bad input"

--reason defaults to a message naming the current user. See the CLI reference for temporal activity terminate for all options.

Important considerations

  • Terminate discards Activity progress unconditionally. Prefer Request Cancel when your code needs to release resources or record a checkpoint.
  • Terminating doesn't delete the record. The closed Execution stays queryable until the Retention Period elapses.