If you can still access a text mode console, or if you can log in remotely:

You can use ps or other process listing tools and kill to try killing some processes. A few programs will save your work (at least to a recovery file) if they receive a kill -HUP or plain kill. They might not have time to do it if you go straight for rebooting.

Run sudo kill followed by a process ID to kill a process that's running as root or some other user who is not you.

Run reboot to reboot (e.g. sudo reboot if you use sudo to gain administrative access). Run halt to power the computer off. Both of these call shutdown with appropriate options.

If absolutely everything is hosed, but you have console access, you can use magic SysRq to at least flush all file changes to disk unmount filesystems cleanly. Press

If it is a frozen X session, hit ctrl+alt+f1 to get to a console. Log in and from there, execute /sbin/shutdown, /sbin/reboot or /sbin/shutdown -r now. Depending on permissions, you may need to prefix these commands with sudo or first su to become root.

You may also be able to kill the offending process. Run ps aux to list all processes and look for ones which are using a lot of CPU and/or memory (third and fourth columns). Use kill <pid>, where pid is the number in the second column of the ps output). If this doesn't kill the process, you may need to run kill -9 <pid> to forcefully kill it.

If your BIOS is setup in a way where you have to press the power-button more than X seconds to actually turn off the machine, press the power-button once. This will give the acpi-signal for shutdown/halt/poweroff.