to terminate a program use the java statement code example Example: how to exit a java program System.exit(0);