# `exit`

_Exit KDB-X_
```syntax
exit x    exit[x]
```

Where `x` is a non-negative integer, stops the KDB-X process with `x` as the exit code.
```q
q)exit 42
```
```bash
$ echo $?
42
```

The operating system keeps only the lowest 8 bits of the exit code, so `exit 256` exits with status 0.
A non-integer argument, such as a float or a symbol, signals a `type` error.

> **Warning — `exit` does not ask for confirmation at the console**
>
>
Before exiting, q calls [`.z.exit`](dotz.md#zexit-action-on-exit) if it is defined.

[`reval`](eval.md#reval) and [`-u 1` on the command line](cmdline.md#-u-disable-syscmds) block `exit` for messages from clients. A blocked `exit` signals an `access` error.

----

[`.z.exit`](dotz.md#zexit-action-on-exit) (action on exit)


[Controlling evaluation](control.md),
[Debugging](../how_to/basics/debug.md)
