1. Graphical: open System Monitor, find the app, right-click, then End or Kill.
2. Terminal: run top (or install htop: sudo apt install htop) to see what's using CPU and memory. Press Q to quit.
3. Close by name: killall firefox
4. Close by number: find the PID in top, then kill 1234. If it won't close: kill -9 1234
5. Whole desktop frozen? Press Ctrl, Alt and F3 to reach a text login, sign in, run top to find and kill the problem, then Ctrl, Alt and F2 (or F1) to go back. Or simply restart.