What to do when my Mac is frozen?

If a computer is totally frozen then you have no alternative but to long-hold to force power off.

This is the same for almost any OS.

The usual indicator on Mac is that not only the app is frozen but you can't access Force Quit & the menu bar clock has stopped. I'd always wait at least 2 or 3 minutes just to be sure it wasn't temporarily too busy to respond, during which time I keep a constant eye on the clock. I actually always have my clock showing seconds precisely for this type of occasion, under potentially extreme processor conditions. Often a process will recover, meaning you don't have to hard power-off & risk losing work.
Patience is a virtue ;)

On a Mac, you should always try to ascertain if it is indeed the entire OS - which is rare - or a single application which has hung.

Holding Cmd ⌘ Opt ⌥ Esc will bring up the Force Quit Applications dialog. This should override any process & come to the front, no matter what else has happened to the Mac. It should highlight any process that is not responding & allow you to force quit it. In many cases this will be sufficient to return to normal operation.
Only if this dialog will not pop up should you consider the Mac itself to be hung [though still keep an eye on the clock, to be sure].

Additional notes -
If you suspect it has hung, don't go clicking around like mad trying to get it to respond. If it's merely been too busy for a minute, then it will suddenly catch up & try to do all the things you were clicking blindly… not necessarily with the best results.
If you are in a fullscreen app & cannot see the menu bar, move the cursor hard to the top of the screen [even if you can't see it] & wait. if the menu bar does eventually drop into view, the Mac hasn't hung.

A Mac is somewhat Unix-like, so there are various options for dealing with a GUI freeze, but you need to set them up in advance:

  • Enabling "Screen Sharing" in the Sharing control panel will let you make a VNC connection from another machine. Since VNC is GUI-based, this is only likely to help in a situation such as a frozen full-screen program, which a second view of your screen might get around.
  • Enabling "Remote Login" in the Sharing control panel will let you SSH in from another machine. If the GUI's frozen, you can try killing various applications to un-freeze it, but your best option is probably just to go for a clean reboot (type sudo reboot at the command line, then enter your password).

If you can't make a network connection to the machine, you're dealing with a hard freeze, and holding the power button is the only option.