I'm reading "Afghanistan: A Military History from Alexander The Great to the Fall of the Taliban" by Stephen Tanner.
In the late 1980s, the US and Soviet leadership met to try to create an organized transition to a post-Communist government in Afghanistan in which Najibullah would be left in power pending internationally supervised elections.
However, this did not come to pass and a civil war broke out between the Uzbeks and Tajiks and the forces of Hekmatyar, who had made a unilateral grab for Kabul and was physically tossed out. The new rulers of Kabul set up a new government (with Ahmed Shah Massoud as defense minister, among other things), but after some internal intrigue, the first president was ejected by Rabbani and this prompted Hekmatyar to start bombarding the city with rockets.
This kicked off a new civil war that ravaged the cities just as the Soviet war had ravaged the countryside.
So...
How can the war be avoided? Hekmatyar being allowed to take Kabul might satisfy him (and the Pashtuns--it was the northern dominance of Kabul that brought about the war), but he doesn't strike me as the sort who plays well with others. He was also the most unpleasant of the resistance whose minions threw acid in the faces of women who didn't veil themselves, so he might be hated by the capital's population.
There's also the obvious solution of Hekmatyar being killed during the war or the advance on Kabul, with the later the death the fewer the butterflies.