I would have to agree with everyone here. This is a toxic personality in your life...she adds nothing positive.
How do you do it? First of all, don't take the bait. Don't have long drawn out discussions with her. You may actually have to be very blunt. You need to decide upon your course of action, and stick with it. If you decide you want to completely end the friendship, then you decide what you want to say, you say it, and you're done. Say it one time, and one time only. And then don't respond to calls, e-mails, visits, or anything else.
If you decide you are going to allow limited positive contact, then the moment the contact becomes less than positive, you need to say "I a m not going to tolerate this behavior, attitude, treatment (you choose the words) from you. I'll be in touch at another time". Then pull back. Quite frankly, the reason she behaves like this is because you have allowed her to, and other people probably have as well.
limit-setting is very hard to do, It is much easier to "give in" but, in the long run, giving in is much more damaging. I am a nurse. Many of the folks I care for are substance abusers who, when they are on my unit, are in the early stages of their detox process, so they will do anything to get their drugs. They will call every 5 minutes, thinking they can "wear you down". They will cry, carry on, scream that they are dying...anything to get you to cave in and give them their drugs. It is very hard to have to keep saying "I know you are having a difficult time but your medicine isn't due until X o'clock, so I'll be back with it then". And, I kid you not, I sometimes repeat that statement hundreds of times in the course of a day. But eventually they get the idea. You have to do the same thing with your friend. Her behavior is bad. She either has to be "trained" to behave better, or you have to cut her out of your life.
Personally, somoeone who has treated me as badly as your friend has treated you would be cut out of my life. I'd tell her once and for all that I could no longer tolerate her bad behavior, constant harping, constant comparisons and constant criticism, so she should not contact me any more. I am all for a clean break in situations like this.