I will usually try a Force Quit first. (Option-Command-Esc), when an app has stopped responding. You will always have the option to force-quit the Finder, Or any app that is listed as "Stopped Responding", or force-quit, even if none are listed as stopped. That's a good likelihood that the system will continue to operate. Or, it could be a hardware issue - and you can press and hold the power button (as you did).
But, I would try force-quit first.
If this freeze happens again, you can check in that Force-Quit window to see if the same app is the culprit each time. If it is something that you have added to the system, you would want to check that there's no updates available, for example.