IPhone 5 keeps randomly shutting off?
Most likely a software glitch you should get it checked
If you are in a really cold or hot place it will shut down automatically to protect itself.
It could also be because you have too many apps running in the background. If this is the problem press the home button twice hold on an app then press a cross