I hate switching off the power on a hung system. As a last resort before doing that, when logging out or even Force Quit won't work, I've had some success with this method. Invoke Spotlight with Command-Space. Even if you don't see the search box appear, keep following these steps. Type Terminal and hit Return. With a bit of luck, you'll see a Terminal window open.
Log into Terminal as an administrator, for example: ssh email@example.com (replace admin with the short name of an administrator account, and mycomputername.local with your computer's Bonjour name (see the Sharing preference pane).
Enter the admin password when prompted. If you get a message that the system can't verify the identity of the computer and asking you if you want to proceed, type yes. Once logged in, you can try any Terminal command and see if it works. Usually, I just type sudo reboot and enter the admin password when prompted.
It's worth a try when it seems that nothing but a cold, hard, power-off restart will work.
Mac OS X Hints