What do I do if Ubuntu 16.04 freezes, but I can move only the mouse?

Well there is a magic key combination (to reboot):

While holding Alt and the SysReq (Print Screen) keys, type REISUB

For more details visit this answer : https://askubuntu.com/a/36717/497359

Switch to the console: CTRL + ALT + F1

After login, you can see which processes are running using this command:

ps -ef

If you see a process which has high CPU usage, you can kill it.

sudo kill <pid>

Of course, you can simply restart the PC too:

sudo reboot