close

fun close(code: Short = definedExternally, reason: String = definedExternally)(source)

The WebSocket.close() method closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.

MDN Reference