# C#: Cancellation

Source: https://tweens.gd/csharp/cancellation/

Awaiting a tween resumes however it ends, cancelled or not. Check the reason when the next step needs the motion to have arrived.

Examples use `using Godot;` and `using tweens.gd;` in a Node method, with targets inside the scene tree.

## Cancel playback

`movement.Cancel()` stops a tween where it is and resumes everything awaiting it. Groups and Chains cancel the same way, and `sprite.CancelTweens(includeChildren: true)` cancels everything a node and its descendants own.

## Continue only on success

Godot's Tween

```csharp
var tween = sprite.CreateTween();
tween.TweenProperty(sprite, "position", new Vector2(400, 180), 0.6);
await ToSignal(tween, Tween.SignalName.Finished); // Not emitted if killed.

sprite.CreateTween().TweenProperty(sprite, "modulate:a", 0f, 0.3);
```

tweens.gd

```csharp
var movement = sprite.TweenPosition((400, 180), 0.6);
if (await movement.End != Reason.Completed)
    return;

sprite.TweenModulateAlpha(0, 0.3);
```

Godot doesn’t emit `finished` for a killed tween, so code awaiting it never continues. `End` always resumes with a reason: here, the fade runs only after the sprite arrives, and never on a sprite freed along the way.

## Why it ended

| Reason | Meaning |
| --- | --- |
| `Completed` | Reached the natural end |
| `Cancelled` | Cancelled through a handle or `CancelTweens` |
| `TargetFreed` | Target was queued for deletion, or found freed or disposed |
| `OwnerExited` | Owner left the tree, or a separate owner was queued for deletion |
| `RunnerDisposed` | Tree or scheduler shut down |

Errors throw instead: a start with invalid arguments throws at the call, and awaiting `End` rethrows a fault from an easing, setter, or callback.

Compare against Completed

A node that owns its tween, as node targets do by default, reports `TargetFreed` after `QueueFree()` but `OwnerExited` after `Free()`, because `Free()` removes it from the tree before deleting it. Test for `Completed` rather than a particular early reason.

## Cancel a wait, not the tween

`await movement.AwaitDecommissionAsync(token)` stops waiting when `token` is cancelled, and throws `OperationCanceledException`. Playback and other waiters continue. Chains have the same method.

[Handles](https://tweens.gd/csharp/api/handles/)Controls, states, wait helpers, and errors.
