# OnDestroy()

> OnDestroy is called to close the EditorWindow window.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.5/script-reference/unityeditor.md)

```csharp
public void OnDestroy()
```

### Remarks

![EditorWindowOnDestroy (OnDestroy())](/api/media?file=/engine/6000.5/media/images/EditorWindowOnDestroy.png) *A simple example of OnDestroy()*

### Examples

```csharp

{code Modules/UIElements/Tests/UIElementsExamples/Assets/EditorWindowCodeExamples/OnDestroyExample.cs}
```
