Psychologically, this often (though not always) is an extended suicide.
In the mind of the person committing it, he is not murdering others. He thinks of the victims as parts of himself. When he decides to end his own life, he includes one or more people whom he considers an integral part of himself. Unfortunately, he rarely asks for their opinion.
In some other cases, the motivation is based on if I can't have you, no one else can. This can happen when a boyfriend tells a girlfriend it's all over (or the other way, of course). That is what apparently happened to Jiri Slitr, the greatest Czech musician of the 1950s-1960s. He was found dead in his appartment with a girl whom he apparently wanted to dump, both killed by gas.
Whatever the motivation it is almost always a selfish act. And always a terrible tragedy.