There is part of us that wants to resolve our unfinished business. We likely unconsciously put ourselves there so we could learn the lesson and complete our unfinished business. Plus, we often need that understanding to create something different.
If we leave the situation before it is resolved, we often create a new similar situation to complete our unfinished business. I call this "revolving door syndrome." The movie Groundhog Day depicted this concept extremely well. When Bill Murray's character completed the lesson, he got to leave his revolving door or "karmic loop."
Therefore if you are stuck in a situation that is not working for you, it may serve you to explore what the lesson is. What are you trying to learn or understand? Then you can complete your unfinished business and move on to something new.
Furthermore, I have found when people resolve their unfinished business, a shift or new doorway will often naturally appear.
On the other hand, once you have learned the lesson, you owe it to yourself to leave. There is nothing there for you anymore.
So... if you do not like your job (or other situation), you get to leave it (for good) when you learn the lesson and complete your unfinished business.