I mean the most obvious answer is when it is no longer fun or you have no money left. If either of those occur, then step away for a long time or forever before you do something you regret.
The most simple answer is when you do not have money left, that our attitude as a gambler because when we are winning we love pushing our luck to earn more even not already in our game plan and because of this most of the time we end up losing. What I am trying to say, without discipline we can never have fun in gambling because we will not initiate the right action on when to leave.