A bad app or download can cause this error to happen. If you can't turn it off let it drain the power till its off and charge up. A hard reset may help, normally on samsung devices its either, hold volume up + home + power or the same except volume down and not up, this will boot up a hidden menu. If all else fail you may need to do a factory reset. Beware a factory reset will wipe the phone clean and you're have to reinstall stuff again. If possible do a backup whenever you can.