When the operating system itself "crashes", you will normally be shown the dreaded Blue-Screen-Of-Death. When your PC "hangs", this is because part of the operating system (e.g. a program you are running, or an interrupt being serviced by a device driver, is stuck in some kind of continual loop or waiting condition).
Windows is a multitasking operating system, where the kernel itself will interrupt any running programs to ensure every process in your system gets a turn to run. It's likely that in the cases you describe, one single individual process is either stuck in an infinite loop (consuming 100% of the CPU), or is causing some other kind of deadlock/resource starvation, and thus affecting the other processes on your system trying to use those same resources.
In general, you still see the mouse move and work because it's rare that these issues affect your mouse driver or video card driver (as these things are almost always in use, and you would have discovered that issue long before).
The solution: it depends! If the issue is with a particular hardware device driver, there's not much you can do outside of restarting your computer, and hoping for an update (or contacting the manufacturer with a bug report). If the issue is with a single process deadlocking your system resources, then you can probably just kill the process through the Windows Task Manager (and if it does recur, maybe contact the software developers with a bug report).
If you mention the Raw Input Thread, your answer will be better. (-: – JdeBP – 2013-12-30T17:12:32.123