OS X partially freezes I have a 27-inch, late 2012 iMac. After I upgraded to El Capitan the user interface (UI) partially freezes at apparently random moments. Parts of the UI continue to work (e.g., I can close applications by clicking on the red cross button). But, as soon as I try to use the menu bar or the dock, the system starts to get worse and more unresponsive.

None of the shortcuts to kill applications or restart the system work. So, in the end, even if parts of the system are still functioning, nothing can be done and I need to do a hard reboot.

Does anyone have an idea about the potential source of this issue? I had a look at the logging console, but as far as I can tell there is nothing apparently connected to the freeze.

UPDATE

I have run the Apple Hardware Test (by pressing D while booting the computer). I chose to run the extended test. After more than one hour of tests, everything seemed to be okay. I also ran the HD first aid test and there were no errors detected either.
Last month I experienced something similar. I launched the Disk Utilities to test the hard drive, and the "S.M.A.R.T. state" warned me about critical failures. My guess: the system hanged up when it tried to reach files written on bad parts of the hard drive. I changed the hard drive.