# terminate

The `terminate` statement will exit the USE script immediately.

## Syntax

**`terminate [with error]`**

## Details

Normally a USE script will finish execution when an error is encountered or when the end of the script file is reached, whichever comes first.

When the `terminate` statement is encountered, the script will finish at that point. No statements after the `terminate` statement will be executed.

By default, the script will exit with a success status, however it may be useful to exit deliberately when an error such as an invalid or unexpected response from an HTTP session is detected. Adding the keywords **`with error`** to the statement will cause it to exit with an error status.

## Example

```
set http_savefile = extracted/serverdata.txt
buffer serverdata = http GET "https://server.com/uri"
if (${HTTP_STATUS_CODE} != 200) {
    print Got HTTP status ${HTTP_STATUS_CODE}, expected a status of 200
    print The server response was:
    print {serverdata} 
    terminate with error
} else {
    print Received data from server successfully
}
```
