Get rid of hang instantly :-
If your phone hangs, to get rid of it instantly, simply remove the battery and after few min reinsert it and start your phone.
In Sony Xperia S, P, GO, U, SL, Z Series
Press the Camera, Volume Up button and Power button simultaneously for 5-10 seconds , phone will restart.
In Nokia Lumia series
Press the volume up or down and power button simultaneously for 5-10 seconds
In Samsung Galaxy S3 S4 S5
Download & install "Dummy file generator" from Google play store.
Open the app and go to internal memory tab.
Select "Generate FULL" and generate dummy files till storage is full.
YES, your phone will hang and freeze couple of times (Just remove & reinsert the battery again).
Keep on generating dummy files till memory if full.
Now, select "Delete", this will delete all dummy files, that's it. Hanging and freezing problem should not occur now.
If nothing helps, feasibly the problem must be a hardware problem and not a software problem. It is recommended to show your mobile phone to an authorized service center.