Hold the power button for 10 seconds.
That’s it. Press and hold the power button (the one with the Touch ID sensor on recent MacBook Airs) for about 10 seconds — the screen will go black and the machine will force shut down.
Wait another second, then press again to turn it back on. You don’t need any key combos or special tricks. The computer is unresponsive, so the only way to break the lock is a hard power-off.
This is safe — it’s designed for exactly this situation. It won’t hurt anything except any unsaved work you’d already lost when the computer froze.
Don’t bother trying to close the lid or tap the trackpad. Just hold the button.