Pretty much what Dervish said. Some people just become toxic, and you have to make sure to keep them at a safe distance or quarantine their toxicity completely so they can't hurt you with it too, no matter how close to them you are.
I myself have felt like isolating myself at times too, but the thought of regret after I've cut all ties has kept me away from the entire idea completely. I'm sure without knowing that I will be undoubtedly lonely if I push away my friends.
It's not selfish, if whoever is causing you grief is just too much to handle, stiff arm them a bit. Don't take anyone for who they used to be, take them for who they are at the time and who they will be and make your decision off of that.