private void killProcesses(String packageName) {
    CommandLine command = adbCommand("shell", "ps");
    String processes = "";
    try {
      processes = ShellCommand.exec(command);
    } catch (ShellCommandException e) {
      String logMessage = String.format("Could not execute command: %s", command);
      log.log(Level.WARNING, logMessage, e);
    }

    for (String process: processes.split("\\r\\n|\\r|\\n")) {
      if (process.endsWith(packageName)) {
        String pid = process.split("\\s+")[1];
        command = adbCommand("shell", "run-as", packageName, "kill", pid);
        executeCommandQuietly(command);
      }
    }
  }
Constructor mean to be used with Android Hardware devices because a reference to the
{@link IDevice} will be available immediately after they are connected.

@param device
selendroid-standalone/src/main/java/io/selendroid/standalone/android/impl/AbstractDevice.java