abstract fun close(cause: Throwable? = null): Boolean(source)

Closes this channel. This is an idempotent operation — subsequent invocations of this function have no effect and return false. Conceptually, it sends a special "close token" over this channel.

Immediately after invocation of this function, isClosedForSend starts returning true. However, isClosedForReceive on the side of ReceiveChannel starts returning true only after all previously sent elements are received.

A channel that was closed without a cause throws a ClosedSendChannelException on attempts to send and ClosedReceiveChannelException on attempts to receive. A channel that was closed with non-null cause is called a failed channel. Attempts to send or receive on a failed channel throw the specified cause exception.