> For the complete documentation index, see [llms.txt](https://fehdead.gitbook.io/npc-kit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/mesclose.md).

# npc.mesclose

```lua
npc.mesclose(slot)
```

|                         |                                    |
| ----------------------- | ---------------------------------- |
| id                      | `0x0012`                           |
| arguments               | 1: Int                             |
| in NPC Kit              | yes                                |
| measured from a kit NPC | returns                            |
| vanilla scripts         | 11806 calls in 709 of 1114 scripts |

## What it does

Closes message window `slot`, one the VM's own window calls opened.

## Arguments

### `slot` (Int)

The window slot, 0 to 7. Vanilla: `0` 7,985 times, `1` 2,538, then `2`, `6`, `5`.

## Timing

Returns at once.

## In NPC Kit

The kit's windows are the Lua Loader's `dialog.*`, which share these slots and close with their handle (`handle:close()` in Lua). Closing one of them by slot from the script is not tested.

## Used with

* [amese](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/amese.md), [messync](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/messync.md): the VM windows it closes.

## Example

A kit window closes with its own handle, from Lua. Here a line that closes itself after three seconds if the player hasn't closed it.

```lua
local hurry = [[
Hurry, hurry! The ship leaves at sundown today,
and the captain won't wait for anyone at all.
]]

talk = function()
    talkOpen();
    npc.lua(function(handle)
        local done = false
        local finish = function()
            if not done then done = true; handle.finish() end
        end
        local window = dialog.amese.open {
            speaker = "NPCKit 0020",
            body = hurry,
            queue = true,
            onClose = finish,
            onError = finish
        }
        if not window then return finish() end
        event.executeAfterMs(3000, function() window:close() end)   -- ends in onClose, reason "closed"
    end);
    talkClose();
end,
```

## Pitfalls

* `npc.mesclose(slot)` closes a VM window by slot; on a `dialog.*` window it is not tested, and its `onClose` may never run, leaving the talk waiting.
