# OnDestroy()

> Called when this system is destroyed.

## Definition

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

```csharp
protected virtual void OnDestroy()
```

### 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.
