ctx.exit()
Terminates the execution of the current event flow; subsequent steps will not run. It is commonly used when business conditions are not met, the user cancels, or an irrecoverable error occurs.
Use Cases
ctx.exit() is generally used in the following contexts where JS can be executed:
ctx.exit()/ctx.exitAll()— Both calls stop the current step and skip the remaining flows in the same sequential event dispatch. Flows already running in parallel continue.
Type Definition
Calling ctx.exit() throws an internal FlowExitAllException, which is caught by the FlowEngine to stop the current event flow execution. Once called, the remaining statements in the current JS code will not execute.
Examples
Exit on User Cancellation
Exit on Parameter Validation Failure
Exit When Business Conditions Are Not Met
Exit Based on User Choice After Modal Confirmation
Notes
- After calling
ctx.exit(), subsequent code in the current JS will not execute; it is recommended to explain the reason to the user viactx.message,ctx.notification, or a modal before calling it. - There is usually no need to catch
FlowExitAllExceptionin business code; let the FlowEngine handle it.
Related
- ctx.exitAll()
- ctx.message: Message prompts.
- ctx.modal: Confirmation modals.

