Should I stay or should I quit? Is there an economic theory of quitting an activity? A theory that weighs the investment costs put into something and the opportunity costs of pursuing it. 

I am aware of Fershtman and Gneezy Quitting in Tournaments paper that investigates the decision of quitting in the middle of a race or of a tournament. But, I am looking for a more general model of quitting something such as playing an instrument, a sport or even a job. Dropping-out from (grad)-school may obey the same investment-opportunity cost trade-off.

Update: I am looking for some explicit references modeling the exiting or quitting process, even if it concerns some decisions in particular without any generalization.

Edit: Here is why I picked @Ubiquitous' answer.
Check out sunk cost. Although this might seem completely counterintuitive, the investment you have made should be irrelevant to your decision to stay or quit, if this investment has already been made and cannot be recovered.

What matters is whether the benefits you are yet to incur outweigh the costs (that you are yet to incur). So the decision should be a forward-looking one.

The above reference mentions that in the real-world, people often do not behave in this way. According to sunk cost theory, this is irrational, but this is only one theory.