> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# WebSocket.Close

> Closes a WebSocket object returned by WebSocket.connect. The first argument must be a table. The function reads the object's connection state; when a live state exists and is not already destroyed or closed, it sets isClosed to true and sends an empty close frame frame with the stored WebSocket connection. It does not accept a close code or reason and returns no values.

Closes a WebSocket object returned by WebSocket.connect. The first argument must be a table. The function reads the object's connection state; when a live state exists and is not already destroyed or closed, it sets isClosed to true and sends an empty close frame frame with the stored WebSocket connection. It does not accept a close code or reason and returns no values.

## Syntax

```lua theme={null}
WebSocket.Close(socket: WebSocket)
```

## Arguments

| Name     | Type        | Required | Description                                                                                                     |
| -------- | ----------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| `socket` | `WebSocket` | Yes      | WebSocket table returned by WebSocket.connect. The function expects this table to contain the connection state. |

## Example

Close a WebSocket object returned by WebSocket.connect.

```lua theme={null}
local socket = WebSocket.connect("wss://example.com/socket")

socket:Close()
```
