All you need is a short letter or email outlining your intention to leave and final dates of employment (last day of your notice period if there is one). How much you feel like explaining is up to you, but this isn’t the right place to document negative feedback; many workplaces will offer an exit interview where you can go into more detail if you want to.