Mclose
Bun

method

WebSocket.close

code?: number,
reason?: string
): void;

Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.

MDN Reference