Settings > Accounts > Back Up and Reset > Factory Data Reset > Reset Device > Delete All/Erase Everything.
Please remember to back up any data you want to keep first! In the Factory reset screen you also have the option to Backup My Data and Auto Restore. These are good options to tick before you Factory Reset if you're not too sure how to do this on your own.
If you're at all paranoid about your SIM card or SD card contents just take them out before you do the Factory Reset. Attention: if you reset your device to the factory default with SD card encryption setting enabled, the device will not be able to read your encrypted files. Disable this setting before resetting the device.
Alternatively, you can type in *2767*3855# on the key pad and that will do the same thing.
Remember sometimes you don't need to go even this far to solve problems. First of all try just turning your phone off for a while, or removing the battery entirely. Sometimes something as simple as that is enough to clear up some simple problems.
But if you've tried all of these methods and are still having problems, you can try a Hard Reset, the instructions for which are here.
Forum Rules - Recommended for new AndroidPIT members! Important to all community members: please read before posting