There is no rule or real answer for your question. The number of chips in your stack is one of the last reasons you should consider when deciding on when to leave. A max buy in rule is an idea to consider, but an arbitrary number for winnings in relation to stopping is nearly irrelevant in my opinion. Ask yourself some other questions, some examples are-- How are you playing? Does it seem like you're "hot"? Are you getting a wave of cold cards? Did the donks all leave? Are you sitting with the best players you've ever seen? Are you tired and hungry? Are you emotionally unstable? Are you still able to maintain focus?
Simply put, are you in an optimal situation to profit and do you have anything better to do? I played a .02 PLO game for 5 hours and left with $87. Max buy-in $2. Arbitrary rules would not have allowed this to happen. That being said, I have got up nice and lost it all before as well. Just keep yourself in good situations.
There is one exception to everything I said. It is a decent idea to have a set number to stop at when your table stack becomes a large percentage of your bankroll. I'm pretty loose in this regard, because I tend to consider only what I'm risking in good situations. I'm sure most people would say if your table stack becomes 10-15% of your total bankroll, you should bank it. I'm positive my earnings would be much less if I adhered to that, but tight bankroll management is paramount to the winning player. I'm not sure it's even possible to be too strict with set bankroll rules.