interruptExecutionOnError = (ctx, subprocess) => {
  let killPromise

  const errorListener = async () => {
    killPromise = killSubprocess(subprocess)
    await killPromise
  }

  ctx.events.on(TASK_ERROR, errorListener, { once: true })

  return async () => {
    ctx.events.off(TASK_ERROR, errorListener)
    await killPromise
  }
}
Interrupts the execution of the subprocess that we spawned if
another task adds an error to the context.

@param {Object} ctx
@param {import('nano-spawn').Subprocess} subprocess
@returns {() => Promise<void>} Function that clears the interval that
checks the context.