I feel your pain - I can take a lot of rubbish in life, but unfair treatment really makes me see red.
The things they're taking credit for, can you put together any evidence of your contribution? Try not to think of it as a complaint, but a review of your achievements - this will be useful to you anyway, because if you are going anyway, you'll need to go through this sort of thing to apply to other jobs anyway.
Do you get an exit interview at all? It needn't stop you if you don't - my last employers got 3 sides of A4* when I went, and I heard a couple of years after than some of the points I raised had improved - no idea if my input made any difference, though.
In the end though, you just need to get over it, especially as writing a complaint letter may not make any difference. Bitterness is not a good emotion, because you're the one who suffers most. If you really are struggling this much, perhaps counselling could be an option, to talk it through, or CBT to find better coping strategies and different ways of thinking about it. Plus all the normal stuff like a healthy diet, regular exercise, enough sleep and so on - you say you're having trouble with this, and the world is always so much harder to deal with when you're sleep deprived. Your immediate health and self-care is within your control, whereas the rest of it may not be, so try to turn the energy you're spending on thinking over the unfairness of it all into caring for yourself. I do know this is far, far easier to say than for you to do (or indeed, for myself to do - this is definitely a "do as I say, not as I do" post!)
- I know, hard to believe I can be a bit verbose, what with my short, pithy posts. Ahem. I would probably advise something shorter for most people.