# OnDestroy(ref SystemState)

> Called when this system is destroyed.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## OnDestroy(SystemState)

```csharp
void OnDestroy(ref SystemState state)
```

### Parameters

**** (\[SystemState]\(/engine/7000.0/script-reference/unity/entities/systemstate)): The [SystemState](/engine/7000.0/script-reference/unity/entities/systemstate.md) backing this system instance

### Remarks

Systems are destroyed when the application shuts down, the World is destroyed, or you call [World.DestroySystem](/engine/7000.0/script-reference/unity/entities/world/destroysystem.md). In the Unity Editor, system destruction occurs when you exit Play Mode and when scripts are reloaded.
