Have you read Wuthering Heights? The narrator, roughly, said: 'I would rather have my father die before me to spare him the pain and leave me to suffer.' You cannot escape being selfish. Either you don't want them hurt because it hurts you, or you cannot bear for yourself to be hurt because then your loved ones will suffer emotionally. Please don't get in philosophy, I never cared to learn about it.
Your motive is to protect the other person and reduce their suffering, not to minimise your own. You're own suffering is not reduced because they won't have to suffer, it makes your loss no less poignant, but you are willing to go through that for them.
Why should the simple fact that you aren't a horrible person and don't particularly want to see them suffer mean all of that has to be disregarded and your act must be deemed selfish?
As I've already mentioned, I think selfishness is determined more by the motives behind your actions, rather than the end result.
You don't act in order to receive the benefit, therefore when you decide to take action your motives are unselfish. Therefore the action itself acted out unselfishly.
If you were to act in order to make yourself feel better, rather than to spare someone else pain, then that'd be different, however so long as that remains as an incidental by-product I can't see why that wouldn't be unselfish.