---
id: "M:cAlgo.API.Plugin.OnStop"
kind: "method"
type: "T:cAlgo.API.Plugin"
url: "https://help.ctrader.com/ctrader-algo/references/General/Plugin/OnStop/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# Plugin.OnStop

Member of [Plugin](https://help.ctrader.com/ctrader-algo/references/General/Plugin/index.md).

## OnStop()

Called when Plugin is stopped.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Plugins cannot run in the CLI: ctrader-cli runs cBots only.
- Cloud: Plugins cannot run in the cloud: it runs cBots only.

C#:

```csharp
protected internal void OnStop()
```

Python:

```python
api.OnStop() -> None
```

### Examples

C#:

```csharp
protected override void OnStop()
{
    // This method is called when the Plugin is stopped
    Print("Plugin stopped at {0}", Server.Time);
}
```

Python:

```python
def on_stop(self):
    # This method is called when the Plugin is stopped
    api.Print(f"Plugin stopped at {api.Server.Time}")
```

