function killTestProcess(instance) {
  if (!instance) {
    return;
  }

  try {
    process.kill(instance.pid);
  } catch (error) {
    if (
      process.platform === 'win32' &&
      typeof error.message === 'string' &&
      (error.message.includes(`no running instance of the task`) ||
        error.message.includes(`not found`))
    ) {
      // Windows throws an error if the process is already dead
      return;
    }

    throw error;
  }
}
@param {import('child_process').ChildProcess | void} instance
@returns {void}