> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Runner instance stopped before it could shut down gracefully

> Resolve the error returned when a Maia runner is stopped while it's still running a component in your pipeline.

## Error message

```text wrap theme={null}
Runner instance was stopped before it could finish gracefully shutting down
```

This error can appear when using the following components: [Database Query](https://docs.maia.ai/docs/components/database-query.md), [Python Script](https://docs.maia.ai/docs/components/python-script.md), [SQL Script](https://docs.maia.ai/docs/components/sql-script.md), and [transformation components](https://docs.maia.ai/docs/components/transformation-pipeline-overview.md).

### Explanation

The Maia runner was told to shut down while it was running a component in your pipeline, and it was stopped before it could finish. This usually follows a deployment, a scale-in event, or a node replacement.

### Potential causes

* A deployment or rolling update replaced the Maia runner while pipelines were running.
* An autoscaler removed an instance that still had active work.
* The shutdown grace period on your platform is shorter than your longest-running component.
* A spot or preemptible node was reclaimed.

***

## Resolve the error

1. Compare the failure time with your deployment history and autoscaling events for the Maia runner.
2. Increase the termination grace period so it covers your longest-running component (for example, `terminationGracePeriodSeconds` in Kubernetes or `stopTimeout` in Amazon Elastic Container Service).
3. Schedule deployments and node maintenance outside the times your pipelines run, or [pause schedules](https://docs.maia.ai/docs/guides/schedules.md) first.
4. Avoid spot or preemptible nodes for Maia runners that run long jobs.
5. Re-run the failed pipeline.
6. If you still need help, [contact Maia Support](https://support.matillion.com/s/) and include the items listed below.

   * The time of the shutdown event.
   * What triggered the shutdown, if known.

### Prevent future errors

To prevent this error occurring again:

* [Keep a minimum number of instances](https://docs.maia.ai/docs/guides/scaling-best-practices.md#maia-runner-instances) running during rolling updates.
* Configure scale-in protection while tasks are active, if your platform supports it.


## Related topics

- [Runner could not finish the task before shutdown](https://docs.maia.ai/docs/errors/runner-could-not-finish-the-task-before-shutdown.md)
- [Shutdown in progress](https://docs.maia.ai/docs/errors/shutdown-in-progress.md)
- [Runner instance offline](https://docs.maia.ai/docs/errors/runner-instance-offline.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.