# Close Button

The close button is an optional UI element that allows users to exit the THNDR experience from within the game. Because THNDR is embedded inside your host application, the close button communicates back to your app via `postMessage`. Your app is then responsible for deciding what to do (close the iframe, navigate away, etc.).

### Enabling the close button

The close button is **shown by default**. If you'd like to disable it, let your THNDR integration contact know.

### postMessage event

When the user clicks the close button, the game emits the following message to the parent window:

```json
{
  "message": "operator_redirect",
  "data": {
    "name": "close"
  }
}
```

Your host application should listen for this message and respond accordingly, typically by closing or hiding the game, or redirecting the user to another screen.

#### Example listener

```javascript
window.addEventListener("message", (event) => {
  if (
    event.data?.message === "operator_redirect" &&
    event.data?.data?.name === "close"
  ) {
    // Close or hide the iframe
    document.getElementById("thndr-iframe").style.display = "none";
  }
});
```

### Confirmation popup (optional)

An optional confirmation popup can be shown when the user clicks the close button, prompting them to confirm before exiting. This is useful if you want to prevent accidental exits mid-session.

This behaviour is **off by default**. If you'd like it enabled, request this when setting up the close button with your THNDR integration contact.

When the confirmation popup is active, the `postMessage` event is only sent after the user confirms they want to leave, not on the initial button click.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thndr.io/integration/customisation/close-button.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
