API Reference › Builtin functions › exit
function

exit

exit(code)

Terminates the process at once with the given status code, without waiting for the current frame to finish. This is a harder stop than quit, which ends the game loop cleanly after the frame completes; use exit for command-line tools and tests that need to signal success or failure to the shell, where 0 conventionally means success and any non-zero value means an error. Because it stops immediately, drawing queued for the current frame is not presented.

Parameters

codethe process exit status (0 for success, non-zero for failure)

Example

program RequireArgument {
  handler CheckArgs phase Start {
    if arg_count() < 2 {
      print(0)
      exit(1)
    }
    print(1)
    exit(0)
  }
}
← All symbols