---
title: "OnGameModeExit | open.mp"
description: "This callback is called when a gamemode ends, either through 'gmx', the server being shut down, or GameModeExit."
canonical: https://omp.itsneufox.com/uk/docs/scripting/callbacks/OnGameModeExit
language: uk
---

# OnGameModeExit

## Description

This callback is called when a gamemode ends, either through 'gmx', the server being shut down, or GameModeExit.

## Returns

This callback does not handle returns.

It is always called first in gamemode.

## Examples

```c
public OnGameModeExit()
{
    print("Gamemode ended.");
    return 1;
}
```

## Notes

Порада

This function can also be used in a filterscript to detect if the gamemode changes with RCON commands like changemode or gmx, as changing the gamemode does not reload a filterscript.

попередження

-   When using OnGameModeExit in conjunction with the 'rcon gmx' console command keep in mind there is a potential for client bugs to occur. An example of this is excessive [RemoveBuildingForPlayer](https://omp.itsneufox.com/uk/docs/scripting/functions/RemoveBuildingForPlayer) calls during [OnGameModeInit](https://omp.itsneufox.com/uk/docs/scripting/callbacks/OnGameModeInit) which could result in a client crash.
-   This callback will NOT be called if the server crashes or the process is killed by other means, such as using the Linux kill command.

## Related Callbacks

The following callbacks might be useful, as they're related to this callback in one way or another.

-   [OnGameModeInit](https://omp.itsneufox.com/uk/docs/scripting/callbacks/OnGameModeInit): This callback is called when a gamemode starts.
-   [OnFilterScriptInit](https://omp.itsneufox.com/uk/docs/scripting/callbacks/OnFilterScriptInit): This callback is called when a filterscript is loaded.
-   [OnFilterScriptExit](https://omp.itsneufox.com/uk/docs/scripting/callbacks/OnFilterScriptExit): This callback is called when a filterscript is unloaded.

## Related Functions

The following functions might be useful, as they're related to this callback in one way or another.

-   [GameModeExit](https://omp.itsneufox.com/uk/docs/scripting/functions/GameModeExit): Exit the current gamemode.
