If you're using an SD card, try unmounting and removing. If no go, try a Cache Partition wipe. If no go, Backup & Reset....let us know if you need advice about backing up your personal data. If no go, the battery or some other internal part may need attention or replacement.
If the battery is loose it will get bumped, the phone shuts down and has to restart. I used to have that problem with mine. I packed the battery so it would be pushed against the contacts and that fixed it