# How to Stop a Test

Stop a running Endtest test from the UI, via the API, or programmatically from a CI/CD pipeline, and configure conditional stop-on-failure rules.

Part of the Endtest documentation (Advanced). Canonical URL: https://endtest.io/docs/advanced/how-to-stop-a-test

---
## Introduction

There are scenarios where you might need to stop a test execution.

There are 3 ways to do that.

### 1. From the Results page

The easiest option is to click on the `Stop Test` button from the Results page.

Deleting a test execution which is in progress will also stop it.

### 2. From inside the test

You can add a `Stop Test` step directly in your test.

The `Stop Test` option is inside the `Miscellaneous` action.

A good practice is to add that step inside an `If Statement`.

For example, if you want to automatically stop a test at a certain point if you have more than 3 failed assertions, you can use a `Variable Condition` in your `If Statement` and check if the system variable `$systemFailedCounter` is greater than 3.

> **Note:** You can find more details about system variables in the [Variables](https://endtest.io/docs/advanced/how-to-use-variables/) chapter.

### 3. With the Endtest API

You can stop a test execution with the Endtest API by using the `stopTest` action.

The unique hash for that test execution must also be provided.

> **Note:** More details are available in the [Endtest API](https://endtest.io/docs/advanced/how-to-use-the-endtest-api/) chapter.
