Waiting for a few minutes (5-10 minutes) is the best solution in such situations.
Actually most of the time when computer hangs, it might be possible that a particular process, application program is taking too much amount of RAM and CPU resources which makes the whole system unresponsive. That’s the first thing which you should do when your machine hangs. Press Ctrl+Shift+Esc Keys Together to Launch Task Manager