Poker is one of those odd games where you win by losing. Not literally -- whether it is a tournament poker game or a cash game, you still want to get all the chips or all the money. However, if you consider folding a bad hand to be losing that hand, than the majority of your success in any given game will come from losing. By folding hands that will not be profitable, you are holding on to money that otherwise would go to your opponents. In a tournament game this means you're holding onto chips, which equals power. In a cash game, you're holding on to cash; and at the end of the day making more cash than what you started with is what it's all about.
There will come a time in a cash game where you should walk away. Whether you are up or down when it comes to dollars earned, when you hit the point where you can't seem to win a hand to save your life, you should consider giving up the ghost and going home. Of course, if you already are at home, such as in the case of online cash games, then you should log off and find something else to do.
This can be equally hard if you are winning or losing. When you are winning, you want to win more -- it's addictive. When you are losing, you want to feel justified for the time and money you've "wasted" playing poker, and you want to win your money back. The fact of the matter is if you're on losing streak, then you're on a losing streak and it's the skilled cash game player who can recognize this.
It will be up to you to determine exactly when you should walk away; but if you've lost half the money you've won, that might be a good sign. If you have lost half the money you started with, that's a great sign. Whether you've won any money or not, if you've gone down to zero then you can't get any clearer sign than that. Don't pull out your ATM card: pull out your car keys and go home.