What do I do when OS X freezes?
A strategy to try when the freeze is actually happening is holding ⌘ Cmd and ⌥ Opt, then hitting ⎋ Escape.

If your keyboard input is still working, this should bring up the force-quit dialog (which can be navigated using the arrow keys and Enter).  This may allow you to close problematic applications without a hard shutdown using the ⌽ Power button.