Question: If you close a GUI using the the little X in the top right of the form, does that kill all your threads as well?

If not, how to you catch that event so I can put in some close down code?

Answer: 
```
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

```

To execute some code on closing have a look at this. [close window event in java](https://stackoverflow.com/questions/1984195/close-window-event-in-java)
> 
> If you close a GUI using the the little X in the top right of the form, does that kill all your threads as well?
> 
> 
> 

Yes, if the default close operation is `EXIT_ON_CLOSE` as mentioned by Luiggi. OTOH it is best not to simply 'kill' threads arbitrarily.

> 
> If not, how to you catch that event so I can put in some close down code?
> 
> 
> 

Set a default close operation of `DO_NOTHING_ON_CLOSE` and add a `WindowListener` or `WindowAdapter`. In the listener, dispose of the GUI and end the threads.

See [How to Write Window Listeners](http://docs.oracle.com/javase/tutorial/uiswing/events/windowlistener.html) for details.