When it becomes too much of a PITA, mechanically and financially, to repair and keep going.
I loved my RT4WD Civic wagon. I also knew, when it started skipping 2nd gear (autotragic), that it was going to be a major job to repair or replace the transmission, and that even finding a suitable replacement was going to be difficult. There's the argument that I could take the opportunity to convert it to a manual, but even that requires some trans mount fabrication because the manual and auto use different mounts. I sold it while it was still running, and was honest about both the good and bad points of the car. The kid I sold it to loved it, problems and all.
My Honda CB750C had all kinds of issues setting in all at once - electrical, dirty carbs, sticky throttle... When Craigslist surfing turned up a freshly rebuilt GS1100L for $350, it was a no brainer to snag it and sell the CB.
My girlfriend has had this basket case of a CRX for 2, almost 3 years now. It's been an endless string of problems. She's put maybe 1000 miles on it the whole time she's had it because it hasn't been driveable long enough to put any more on. And yet, she has so much money into the project that she doesn't want to cut her losses and sell it. She wants to eventually get some use out of the car she's put so much into. Personally, I think the car is cursed, but she doesn't like me saying that.