code: public static void kill(final long pid) throws IOException, InterruptedException {
      if (isUnix()) {
        final Process process = new ProcessBuilder()
            .command("bash", "-c", "kill", "-9", String.valueOf(pid))
            .start();
        final int returnCode = process.waitFor();
        LOG.fine("Kill returned: " + returnCode);
      } else if (isWindows()) {
        final Process process = new ProcessBuilder()
            .command("taskkill.exe", "/f", "/pid", String.valueOf(pid))
            .start();
        final int returnCode = process.waitFor();
        LOG.fine("Kill returned: " + returnCode);
      } else {
        throw new UnsupportedOperationException("Unable to execute kill on unknown OS");
      }
    }
docs: Kill the process.
  
  @param pid Process id
  @throws IOException