I think you need to set two goals, first one is how much you want to spend, and the second one is when you gonna stop, how much you want to get. You win or you lose it doesn't matter just stop after your limit is reached.
In fact, before you even step into a casino or probably online gambling, you should not even start gambling with what you cannot afford to lose, and in most cases for casino, just go with the amount you really want to gamble with in your hands just to be on the safer side. Once you are done, then you are done, as long as you have nothing left, it would be easy for you to stop and call it a day.
You can stop and call it a day when you make 10% profit, like you have 100$ and after some time of playing you have 110$, you can stand up and walk away with 10% profit, but people are greedy and its easier to blame gambling and casino for losing then yourself. When do you know its time to stop can depends from how much control you have, for some people going to 0 is a stop sign, some people borrow money and continue to gambling with hopes for some big win and returning everything that is lost.
Setting goals in gambling is hard, first you never know what will happen, second games leads you to believe its your night, big win or lose can make your brain working like crazy and its hard to stand up if you won something big and you think its your night, we pursue some high goals that are hard to reach in gambling.