Dispose will usually do what you tell it to do by calling the setDefaultCloseOperation(...) on your JFrame with proper parameter, which I think for you will be (JFrame.DISPOSE_ON_CLOSE.
...