My Lumia 520 is now restarting by itself suddenly the screen will stop responding and when I press the screen lock button two things might happen first it gets fixed and other times it just restarts any thoughts of why is this happening?
Check the question Why does my Nokia Lumia 520 automatically switch off?
I think that can help.
Also, try Stop Restart App (link) by Microsoft.
Let me know if the problem is fixed.