You can cancel a job simply by calling cancel() on it.

If you run this snippet, the first coroutine is canceled by the second coroutine. The first coroutine is blocking on the delay() when the second coroutine cancels it, so the first coroutine never completes the work, including never printing the "after the first delay" message.

You can learn more about this in:
Run Edit