You should not use System.exit(). There is no need for it.
Whenever the last non-daemon
Thread terminates, the JVM will exit automatically. You have a single-threaded application, so you only have one non-daemon Thread, which starts the main method and is called "main". When you reach the end of the loop, you go back to the main method, and when the main method returns (it always "returns" but being "void" returns "nothing"), the main Thread terminates and the JVM closes naturally.
What you actually mean is, how do you exit your loop. Using System.exit() to exit a loop would not be good design. You need some sort of prompt, like this, at the
end of your loop:
followed by a
test whether you have entered "yes", maybe using
this method. You can easily work out the rest yourself.