killSubprocess = async (subprocess) => {
  const childProcess = await subprocess.nodeChildProcess

  try {
    const childPids = await pidTree(childProcess.pid)
    for (const childPid of childPids) {
      try {
        process.kill(childPid)
      } catch (error) {
        debugLog(`Failed to kill process with pid "%d": %o`, childPid, error)
      }
    }
  } catch (error) {
    // Suppress "No matching pid found" error. This probably means
    // the process already died before executing.
    debugLog(`Failed to kill process with pid "%d": %o`, childProcess.pid, error)
  }

  // The child process is terminated separately in order to get the `KILLED` status.
  childProcess.kill('SIGKILL')
}
Kill subprocess along with all its child processes.
@param {import('nano-spawn').Subprocess} subprocess