# Controlling when your loading screen closes (loadscreen_manual_shutdown)

> How loadscreen_manual_shutdown works in FiveM: keep the loading screen visible until your character selector or spawn is ready, close it with ShutdownLoadingScreenNui, fade out smoothly, and avoid the classic stuck-forever mistake.

Source: https://fam-tools.com/guides/fivem-loadscreen-manual-shutdown · FAM Tools · published 2026-09-11 · updated 2026-09-11 · about 10 min

**Short answer.** Add `loadscreen_manual_shutdown 'yes'` to the loading screen’s fxmanifest.lua. The screen then stays up after loading finishes until a client script calls `ShutdownLoadingScreenNui()`. Call it from the resource that knows the player is ready — usually the multicharacter or spawn script — and always have a fallback so a failed script cannot leave players stuck.

## Key points

- `loadscreen_manual_shutdown 'yes'` goes in the **loading screen** resource’s manifest.
- Close it from any client script with `ShutdownLoadingScreenNui()`.
- `ShutdownLoadingScreen()` closes the game’s own loading screen; you usually call both.
- `SendLoadingScreenMessage(json)` lets scripts talk to the page before it closes (for a fade).
- Always add a safety timeout — manual shutdown without a shutdown call means stuck players.

By default the loading screen disappears the instant the game has loaded — often a second or two before your character selector, spawn camera or framework is actually ready, which leaves players staring at a frozen, half-loaded world. Manual shutdown lets you keep the loading screen up until your scripts say so, and close it with a fade instead of a cut.

## What happens by default

Without manual shutdown, FiveM closes the loading screen when the game finishes loading the session. Your framework may still be fetching the character list, the spawn selector may not have opened, and the player sees the raw game world for a moment — sometimes under the map, sometimes mid-air.

## Enabling manual shutdown

*fxmanifest.lua (the loading screen resource)*

```lua
fx_version 'cerulean'
game 'gta5'

loadscreen 'index.html'
loadscreen_manual_shutdown 'yes'

files { 'index.html', 'style.css', 'script.js' }
```

*client.lua (your spawn or multicharacter resource)*

```lua
-- Call when the player can see something worth seeing
local function closeLoading()
    ShutdownLoadingScreen()     -- the game's own loading screen
    ShutdownLoadingScreenNui()  -- your HTML loading screen
end
```

The shutdown call can come from any client script, not only the loading screen’s own resource. That is the point: the resource that knows the player is ready decides.

## Frameworks and multicharacter scripts

Most multicharacter and spawn-selector resources already call `ShutdownLoadingScreenNui()` when their UI opens. If you enable manual shutdown and use one of them, check that it does — search its client files for `ShutdownLoadingScreenNui`. If it does not, add the call where its interface becomes visible.

> **The stuck-forever mistake** — Manual shutdown plus nothing calling `ShutdownLoadingScreenNui()` leaves every player on the loading screen indefinitely. It is one of the causes in [stuck on the loading screen](https://fam-tools.com/guides/stuck-on-loading-screen).

## A safety fallback

*client.lua — never leave players stuck*

```lua
CreateThread(function()
    -- If nothing has closed the loading screen 45 s after the session started, close it.
    while not NetworkIsSessionStarted() do Wait(500) end
    Wait(45000)
    ShutdownLoadingScreen()
    ShutdownLoadingScreenNui()
end)
```

Calling the shutdown natives when the screen is already closed does nothing, so the fallback is harmless when everything works.

## Fading out instead of cutting

Before closing, send the page a message so it can fade to black, then shut it down a moment later. On the game side, fade the screen in from black once the loading screen is gone for a clean transition.

*client.lua*

```lua
SendLoadingScreenMessage(json.encode({ action = 'fadeOut' }))
Wait(800)
ShutdownLoadingScreen()
ShutdownLoadingScreenNui()
DoScreenFadeIn(600)
```

*script.js (loading screen)*

```javascript
window.addEventListener('message', (e) => {
  if (e.data && e.data.action === 'fadeOut') {
    document.body.style.transition = 'opacity .7s ease';
    document.body.style.opacity = '0';
    const audio = document.querySelector('audio');
    if (audio) fadeVolume(audio, 700);
  }
});

function fadeVolume(audio, ms) {
  const start = audio.volume;
  const t0 = performance.now();
  (function step(now) {
    const k = Math.min(1, (now - t0) / ms);
    audio.volume = start * (1 - k);
    if (k < 1) requestAnimationFrame(step);
  })(t0);
}
```

## Questions

### What does loadscreen_manual_shutdown do?

It keeps the loading screen visible after the game has loaded, until a client script calls `ShutdownLoadingScreenNui()`.

### Where do I put loadscreen_manual_shutdown?

In the fxmanifest.lua of the loading screen resource, next to the `loadscreen` line.

### Which script should close the loading screen?

The one that knows the player is ready — usually your multicharacter or spawn-selector resource. It calls `ShutdownLoadingScreenNui()`.

### Why are my players stuck on the loading screen after enabling manual shutdown?

Nothing calls `ShutdownLoadingScreenNui()`. Add the call where your spawn UI opens, plus a safety timeout.

### What is the difference between ShutdownLoadingScreen and ShutdownLoadingScreenNui?

`ShutdownLoadingScreen` closes the game’s own loading screen; `ShutdownLoadingScreenNui` closes your HTML loading screen. Spawn scripts usually call both.

## Related

- https://fam-tools.com/guides/stuck-on-loading-screen
- https://fam-tools.com/guides/fivem-loading-screen-progress-bar
- https://fam-tools.com/guides/fivem-loading-screen-handover-data
- https://fam-tools.com/guides/fxmanifest-loadscreen
