Note: You may have to register with SamMobile to download the firmware file. Both the download and registration are free. (The download may take longer if you are not a premium member).
(S4 model number: SGH-i337M)
On the download page, scroll down to 'Instructions'. You'll see a link to download Odin v3.10.6. Odin is a utility used to write or flash the firmware file to your phone. Instructions are also provided on how to place your phone in 'download mode' and install the firmware to your device. For best results, use the USB cable that originally came with your S4.
Once the phone reboots with the KitKat operating system, you'll want to go to: Settings > About device > Software update and uncheck Auto update. This will prevent the device from automatically/accidentally installing Lollipop. Mobile data will also re-enable itself after this procedure, be sure to disable it, if you don't intend to use data.
Let us know if you have any further questions or if you get stuck with something.
I have the same problem, the smartphone shuts off or restarts by itself. I once saw the Samsung logo as if the smartphone goes off, but the other times, it occured with the screen off... I bought it refurbished (Bell version) and came with the lastest lollipop version (I337MVLUGOH1)
Cleaned battery pins, checked the power button, reinstalled Lollipop from Kies, did two factory resets... Nothing fixed it.
I saw this post and did these steps..
I downloaded the files from (https://www.androidfilehost.com/?w=search&s=i337m&type=files)
1- installed Kitkat 4.4.2 with Odin 3.09 (I337MVLUFNI2) (did a factory reset with home button + vol up, it was stuck with Samsung logo)
2- installed Lollipop 5.0.1 with Odin 3.09 (I337MVLUGOC4) (factory reset)
3- Updated by OTA for stagefright update (I337MVLUGOH1) (~233mb download)
It seems to be fixed for now...
I'll keep updated if the problem occurs again.