---
id: api/cypress-api/stop
title: Cypress.stop() | Cypress Documentation
description: Stop Cypress on failure or any other conditions
section: api
source_path: docs/api/cypress-api/stop.mdx
version: e6988a974973e9090ce70406c38cb2b9e0eac9fa
updated_at: '2026-05-15T15:50:22.536Z'
---
# Cypress.stop

Stop the Cypress App on the current machine while tests are running. This can be useful for stopping test execution upon failures or other predefined conditions.

**Auto Cancellation**: If you're looking to automatically stop _all tests_ across _multiple machines_ when a test fails, consider using the [Auto Cancellation feature](/llm/markdown/cloud/features/smart-orchestration/run-cancellation.md) in Cypress Cloud.

**Benefits:** Stopping a test run on the first failure across parallelized machines will:

1.  **Save time.** Identify failures early and resolve issues faster.
2.  **Reduce CI costs.** Cut down on unnecessary test execution, leading to significant savings for large test suites.
3.  **Free up CI resources.** Prioritize critical tests and keep CI pipelines available for validating fixes.
4.  **Optimize future runs.** With **[Spec Prioritization](/llm/markdown/cloud/features/smart-orchestration/spec-prioritization.md)** and **Auto Cancellation**, failed tests run first in the next attempt, stopping early if issues persist to maximize efficiency.

## Syntax

```
Cypress.stop()
```

## Examples

### Stop tests when a test fails

To ensure tests stop immediately after a failure across any spec file, add the following snippet to your `support/index.js` file:

```
afterEach(function () {  if (this.currentTest.state === 'failed') {    Cypress.stop()    return  }})
```

### Abort tests when a condition is met

```
beforeEach(() => {  if (env !== 'expected-condition') {    cy.log('Stop tests - environment is not setup correctly')    Cypress.stop()    return  }})
```

## Notes

Calling `Cypress.stop()` will stop the execution of remaining tests, but any code after `Cypress.stop()` in the same container block (such as `beforeEach` or `afterEach`) will still run. To prevent additional logic from executing after `Cypress.stop()`, add a `return` statement immediately after it:

```
if (someCondition) {  Cypress.stop()  return // Prevents further code execution in this block}
```

### `cypress run` vs `cypress open` behavior

Calling `Cypress.stop()` during `cypress run` will skip any remaining tests in the current specfile. If recording to Cypress Cloud, all screenshots, videos, and [Test Replay](/llm/markdown/cloud/features/test-replay.md) will still successfully upload.

Calling `Cypress.stop()` during `cypress open` will stop execution of the Cypress App, but remain open for inspection. The remaining tests will not run.

### Why choose Auto Cancellation?

[Auto Cancellation](/llm/markdown/cloud/features/smart-orchestration/run-cancellation.md) is available with Cypress Cloud's Business+ plan. It offers several advantages over `Cypress.stop` for stopping tests on **failure**:

1.  **Scope of Cancellation:** `Cypress.stop` halts only the current spec file, skipping remaining tests within it. Auto Cancellation, however, stops all tests across all machines and marks the entire run as **cancelled** in Cypress Cloud for better visibility.
2.  **Configurable Thresholds:** Auto Cancellation allows you to define failure thresholds. `Cypress.stop` executes immediately when the specified condition is met.
3.  **Simplified Configuration**: Auto Cancellation settings can be managed in Cypress Cloud, whereas `Cypress.stop` requires manual code changes.
4.  **Optimization with Spec Prioritization**: Combined with [Spec Prioritization](/llm/markdown/cloud/features/smart-orchestration/spec-prioritization.md) (another Business+ feature), Auto Cancellation helps efficiently allocate resources by running previously failing specs first in a new run.

To get started with Cypress Cloud, [sign up](https://cloud.cypress.io/signup) to start your **30 day free trial** - including all premium Cypress Cloud features and plenty of test results to let you experience the power of Cypress Cloud!

## See also

*   [Auto Cancellation](/llm/markdown/cloud/features/smart-orchestration/run-cancellation.md)
*   [`Cypress.currentTest`](/llm/markdown/api/cypress-api/currenttest.md)
*   [`Cypress.currentRetry`](/llm/markdown/api/cypress-api/currentretry.md)
*   [Load Balancing](/llm/markdown/cloud/features/smart-orchestration/load-balancing.md)
*   [Parallelization](/llm/markdown/cloud/features/smart-orchestration/parallelization.md)
*   [Spec Prioritization](/llm/markdown/cloud/features/smart-orchestration/spec-prioritization.md)
