How to get a sample (aka stack trace) when an application becomes unresponsive or beach balls:
1. Open the Activity Monitor (located in Applications/Utilities/)
2. Find the application that is hanging in the list and click on it's row to highlight it. It will most likely be highlighted in red to indicate that it is unresponsive.
3. Click the Inspect button to open the information panel for the selected application.
4. Click the Sample button to obtain a stack trace. This contains information about what is causing the beach ball. Select and copy the text, or click the "Save..." button.
5. Once you have obtained the sample of the hanging application, you can use the Quit Process button in the main Activity Monitor window to Force Quit the program.