Well yes and no. Yes there were many points in the conflict when the Soviets had clearly won the day and the Afghans probably should have quit. But for a variety of reasons (some internal to them, some tied to US aid) they didn’t. In an attrition war the home team will always be the most motivated, and eventually will always win, because eventually the other side just gets tired of it. Even in a dictatorship the will of the people matters, and when those people decide they’re tired of burying their sons for a cause they don’t believe in the war will end.
The issue is outside aid to insurgents and how that keeps them going. The Taliban frustratingly are both fought by and backed by Pakistan at the same time. It’s just a bizarre situation - probably because Pakistan is a failed state and within Pakistan there are competing factions.