This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
n.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) to exit, or n.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE) to only close the frame, letting the JVM exit automatically if it's the last window and there are no other threads active.
EXIT_ON_CLOSE and System.exit(0) can be hazardous if there is anything else going on, for example writing to a file in a different thread. That might terminate the other thread, too, leaving the file incomplete or corrupt. Dispose would be better; the JVM will continue to run until the file writing is completed and the other thread terminates.