code: public static void terminateProcessGroup(String pgrpId) {
      ShellCommandExecutor shexec = null;
      try {
        String[] args = { "kill", "--", "-" + pgrpId };
        shexec = new ShellCommandExecutor(args);
        shexec.execute();
      } catch (IOException ioe) {
        LOG.warn("Error executing shell command " + ioe);
      } finally {
        LOG.info("Killing all processes in the process group " + pgrpId +
                 " with SIGTERM. Exit code " + shexec.getExitCode());
      }
    }
docs: Sends terminate signal to all the process belonging to the passed process
  group, allowing the group to gracefully exit.
  
  @param pgrpId process group id