The very last communication a program has with its environment occurs when it terminates itself. A Java application can terminate itself by calling the System.exit() method. This method terminates an application by exiting the Java virtual machine; its argument is the exit code that is returned to the environment that invoked the Java virtual machine.
If a program is running in a browser or other environment that has a SecurityManager installed, it may be denied the ability to call System.exit().