Fixing a Hang
Sometimes Mac OS X might stop responding to the mouse or keyboard or only respond slowly. For example, it might take a long time for a program to launch, menus or windows might re-draw slowly, or things might seem to completely stop. Unless you see the kernel panic screen, telling you to restart, the system hasn't really crashed so you could try some of the techniques mentioned here.
Try to launch the terminal. Even if the machine is slow, be patient. Display the processes using most of the CPU by using top -u 10. After a few seconds it should be obvious which process is "hogging" the CPU. Make a note of its process number (the first number in the PID column) and its name (second column).
If the process is a program you are running and the program isn't doing something that is really CPU intensive (for example, calculating stats for a couple of million numbers or something) try quitting it normally. If it won't respond try command-option-escape and force quit it. If this doesn't work try the kill command in the terminal. Try kill -9 xxx, where xxx is the process ID number.
If the machine is so unresponsive that you can't run terminal you could try checking it over the network (or Internet) from another computer. The remote login must be already set up on the problem machine for this to work. See the Remote Secure Login section for details. Use ssh name@computer from a working computer, where name is the short name of the administrator of the problem machine and computer is the domain name or IP address of the problem machine. Enter the administrator's password then use the commands above (top and kill) to terminate the problem process.
When you figure out which process is causing the problem you should try to fix the error. If the process is network related (eg inetd) there might be something happening on your network (a packet storm or denial of service attack, for example). If the process is a driver (for example for a scanner) you might want to check connections, update the driver, or use the device without a driver, if possible.
More information: Getting Started.