@Override
    public void uncaughtException(Thread thread, Throwable ex) {
      File crashLogFile = ExternalStorage.getCrashLog();
      String outputPath = crashLogFile.getAbsolutePath();

      PrintWriter pw = null;
      try {
        pw = new PrintWriter(crashLogFile);
        ex.printStackTrace(pw);
        pw.flush();

        SelendroidLogger.info("Process has crashed, log has been written to: " + outputPath);
      } catch (Exception logEx) {
        SelendroidLogger.error("Could not write crash log to: " + outputPath, logEx);
      } finally {
        if (pw != null) {
          pw.close();
        }
      }

      System.exit(-1);
    }
Handle uncaught exceptions by logging them to the crash log file, then kill the application.
selendroid-server/src/main/java/io/selendroid/server/UncaughtExceptionHandling.java