close

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

The WebSocket.close() method closes the WebSocket connection or connection attempt, if any.

MDN Reference