# Cancellation and termination

> For the complete documentation index, see [llms.txt](https://docs.temporal.io/llms.txt).
> Any documentation page is available as raw Markdown by appending `.md` to its URL.

A business process that's already running sometimes has to stop: an order is retracted, a customer closes an account, a
deploy goes wrong. Temporal gives you two ways to stop a
[Workflow Execution](/workflow-execution), and the difference between them is whether your code gets to clean up after
itself.

**Cancellation** asks the Workflow to stop. The Workflow receives the request, so it can release resources, undo steps it
has already taken, and notify other systems before closing. The steps it takes are your code, so you decide what
unwinding a half-finished process means.

**Termination** closes the Workflow Execution immediately. Workflow code never sees the request and no cleanup runs. It
works on a Workflow that can't respond to anything, which is what makes it the fallback when Cancellation won't land.

## What this means for your design

- **You write the cleanup.** Temporal delivers the Cancellation request and
  schedules a Workflow Task so your code can act on it. You can specify what to undo, and in what order. If your
  process reserves inventory, charges cards, or provisions infrastructure, plan the unwind path alongside the forward
  one. See the [Saga Pattern](/design-patterns/saga-pattern) for the usual structure.
- **Long-running Activities need Heartbeats to be cancellable.** Cancellation reaches an Activity when it Heartbeats, so
  an Activity that never Heartbeats runs to completion regardless. This shapes how you write anything long-running.
- **You always have a way out.** A Workflow blocked by a bug, a bad deploy, or a missing Worker can still be terminated,
  so a stuck process is never permanently stuck.
- **The record survives the stop.** Both operations are recorded in
  [Event History](/workflow-execution/event#event-history) with who requested it and why, which matters for audit and
  incident review.

Cancellation and Termination close a Workflow for good. To hold one in place and resume it later, see
[Workflow Pause](/encyclopedia/workflow/workflow-pause).

## Resources

Read the Temporal Encyclopedia for conceptual depth:

- [Cancellation and Termination](/encyclopedia/workflow/cancellation-and-termination)
- [Parent Close Policy](/parent-close-policy)

Or jump straight to the SDK feature guide for implementation details:

- [.NET SDK](/develop/dotnet/workflows/cancellation): Handle Cancellation and Termination in C# and .NET.
- [Go SDK](/develop/go/workflows/cancellation): Handle Cancellation and Termination in Go.
- [Java SDK](/develop/java/workflows/cancellation): Handle Cancellation and Termination in Java and other JVM languages.
- [PHP SDK](/develop/php/workflows/cancellation): Handle Cancellation and Termination in PHP.
- [Python SDK](/develop/python/workflows/cancellation): Handle Cancellation and Termination in Python.
- [Ruby SDK](/develop/ruby/workflows/cancellation): Handle Cancellation and Termination in Ruby.
- [Rust SDK](/develop/rust/workflows/cancellation): Handle Cancellation and Termination in Rust.
- [TypeScript SDK](/develop/typescript/workflows/cancellation): Handle Cancellation and Termination in TypeScript and JavaScript.
