If your machine has errors with the hard disk and your machine has booted with a read-only filesystem, these commands can force your machine to either shutdown or reboot.
Forced re-boot.
echo 1 > /proc/sys/kernel/sysrq echo b > /proc/sysrq-trigger |
Forced shutdown.
echo 1 > /proc/sys/kernel/sysrq echo o > /proc/sysrq-trigger |
Execute these commands at a root prompt and they will work instantly. Communicating directly with the kernel this way allows you to shutdown gracefully even if traditional commands will not work at all.
This is where I got these commands from: http://linoxide.com/how-tos/inputoutput-error-bad-blocks-how-to-restart-linux/.