Stay organized with collections
Save and categorize content based on your preferences.
You can use return in the main workflow to stop a workflow's execution. You
can also finish a workflow by simply completing the final step (assuming that
the step doesn't jump to another).
A workflow's execution stops when one of the following occurs:
When the keywords end or return are used in the main workflow
Use end
In the main workflow, you can use next: end to stop a workflow's execution if
you don't need to return a value. A main workflow that executes a next: end
step completes with null as the result.
In a subworkflow, you can use next: end in a step to make it the last step in
the subworkflow and return null. It does not need to be in a separate step
(unlike return) and can be used in any step. When using either next: end or
return, control is returned to the calling subworkflow.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Complete the execution of a workflow\n\nYou can use `return` in the main workflow to stop a workflow's execution. You\ncan also finish a workflow by simply completing the final step (assuming that\nthe step doesn't jump to another).\n\nA workflow's execution stops when one of the following occurs:\n\n- An [error is raised and not caught](/workflows/docs/reference/syntax/catching-errors)\n- After all steps have been executed\n- When the keywords `end` or `return` are used in the main workflow\n\nUse `end`\n---------\n\nIn the main workflow, you can use `next: end` to stop a workflow's execution if\nyou don't need to return a value. A main workflow that executes a `next: end`\nstep completes with `null` as the result.\n\nIn a subworkflow, you can use `next: end` in a step to make it the last step in\nthe subworkflow and return `null`. It does not need to be in a separate step\n(unlike `return`) and can be used in any step. When using either `next: end` or\n`return`, control is returned to the calling subworkflow. \n\n### YAML\n\n```yaml\n - STEP_NAME:\n ...\n next: end\n \n```\n\n### JSON\n\n```json\n [\n {\n \"\u003cvar translate=\"no\"\u003eSTEP_NAME\u003c/var\u003e\": {\n ...\n \"next\": \"end\"\n }\n }\n ]\n \n```\n\nUse `return`\n------------\n\nUse `return` to stop a workflow's execution and return a value, variable, or\nexpression: \n\n### YAML\n\n```yaml\n - STEP_NAME:\n ...\n return: ${\u003cvar translate=\"no\"\u003eVARIABLE\u003c/var\u003e}\n \n```\n\n### JSON\n\n```json\n [\n {\n \"\u003cvar translate=\"no\"\u003eSTEP_NAME\u003c/var\u003e\": {\n ...\n \"return\": \"${\u003cvar translate=\"no\"\u003eVARIABLE\u003c/var\u003e}\"\n }\n }\n ]\n \n```"]]