Why Does My iPhone 5 Keeps Going Back To The Home Screen When I'M Using An App Or Playing A Game? Here's The Fix.
You may need to do a restore to fix it. Do a backup and then connect to iTunes and do a restore from the backup. If it continues after that, then it may be a hardware issue.