Mac is freezing. How to find the problem?
Try using Apple Diagnostics to check for hardware issues:
Restart your computer, then hold down the D key while the Mac restarts.

Check Apple knowledge base on this subject - https://support.apple.com/kb/PH21879

If you get an error-code, check this page for how to follow it up:
https://support.apple.com/en-us/HT203747