Use EXIT_ON_CLOSE for JFrame.