Do you know about alt-sysReq + R E I S U B? If you can't do anything but
the keyboard still responds it does a safe reboot closing open files etc.
Hold down alt-Sysreq and press the keys one at a time, pausing long enough
to be sure there is no more disk activity after each - maybe 15 seconds. To
shut right down use REISUO (letter "o", not number).
This almost always works and gives a clean shutdown or reboot. It's true
your way works most of the time but REISUB protects the file system and is
safer.