If it locks up completely, you can REISUB it, which is a safer alternative to just cold rebooting the computer.
REISUB by:
While holding Alt and the SysReq (Print Screen) keys, type REISUB.
R: Switch to XLATE mode
E: Send Terminate signal to all processes except for init
I: Send Kill signal to all processes except for init
S: Sync all mounted file-systems
U: Remount file-systems as read-only
B: Reboot
REISUB is BUSIER backwards, as in "The System is busier than it should be", if you need to remember it. Or mnemonically - R eboot; E ven; I f; S ystem; U tterly; B roken.
This is the SysReq key:
NOTE: There exists less radical way than rebooting the whole system. If SysReq key works, you can kill processes one-by-one using Alt+SysReq+F. Kernel will kill the mostly «expensive» process each time. If you want to kill all processes for one console, you can issue Alt+SysReq+K.
NOTE: You should explicitly enable these key combinations. Ubuntu ships with sysrq default setting 176 (128+32+16), which allows to run only SUB part of REISUB combination. You can change it to 1 or, which is potentially less harmful, 244. To do this:
sudo nano /etc/sysctl.d/10-magic-sysrq.conf
and switch 176 to 244; then
echo 244 | sudo tee /proc/sys/kernel/sysrq
It will immediately work! You can test this by pressing Alt+SysReq+F. For me, it killed active browser tab, then all extensions. And if you will continue, you can reach X Server restart.
More info on all the Alt+SysReq functions here.