It's easy to forget to quit the application when the window is closed. Remember to add the following line.
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); //Quit the application when the JFrame is closed