Formating and reinstaling OS on Galaxy S4
There are 2 ways:


Get the stock ROM which works with root from sammobile.com. Make sure that Kies isn't running. Then, flash the ROM with Odin, or,
Unroot using the custom recovery by downloading a completely stock normal ROM from sammobile which should get rid of root.