> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-en/action-guides/workflow/exit-loop.md).

# Exit loop

Exit loop is the action used to forcefully exit the current loop (For or While) immediately, regardless of whether the loop has completed its designated number of iterations. After exiting, the system will continue to execute the actions immediately following that loop block.

This action is often placed within an If conditional block to handle unusual situations or when the necessary result has been found ahead of time.

#### Real-world example: Stop checking when a valid account is found

Suppose you use a For loop to scan through a list of 100 accounts in an Excel file to find an account with the status of `"Live"` to use. If line number 5 is already a "Live" account, you do not need to waste time running through the remaining 95 lines.

* Configuration method:
  * Inside the For block, you use the If statement to check: `If status = "Live"`.
  * In that If block, you handle retrieving the account and then call the Exit loop action.
* Result: The system runs to line number 5, sees the condition is true, immediately jumps out of the For loop, and continues executing the subsequent actions to proceed.

<figure><img src="/files/UOLFjW2J0V5TWHOyxoDl" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-en/action-guides/workflow/exit-loop.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
