cancel

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

Cancels Job of this context with an optional cancellation cause. The result is true if the job was cancelled as a result of this invocation and false if there is no job in the context or if it was already cancelled or completed. See Job.cancel for details.