cancel

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

Cancels reception of remaining elements from this channel. This function closes the channel with the specified cause (unless it was already closed), removes all buffered sent elements from it, and cancels all open subscriptions. This function returns true if the channel was not closed previously, or false otherwise.

A channel that was cancelled with non-null cause is called a failed channel. Attempts to send or receive on a failed channel throw the specified cause exception.