# shutdown (Server)

> Shuts the server down. It fires `onShutdown` first.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Server
- **URL**: https://wiki.mymp.gg/en/shutdown

## Syntax

```lua
bool shutdown([string reason = "No reason specified", int exitCode = 0])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `reason` | `string` | The reason, which goes to the log and to `onShutdown`. *(default: `"No reason specified"`)* |
| `exitCode` | `int` | The process's exit code, useful to a script that restarts the server. *(default: `0`)* |

## Returns

`true`.

## Example

```lua
addCommandHandler("restartserver", function(player)
    shutdown("Restart requested by " .. getPlayerName(player), 1)
end)
```

## See also

- [onShutdown (Server)](https://wiki.mymp.gg/en/onShutdown.md): Fired when a script calls shutdown, right before the server shuts down.
