Early in our marriage, my wife left me. At the time, it was the worst form of rejection I’d ever felt. Depressed and angry, I let it affect my work and, about six months later, I discovered a new form of rejection: I was fired.

Now, I’m not going to sit here and say that my experience was any worse than anyone else’s. On the contrary, the CEO made it part of a broader layoff that included another executive, and the terms were quite generous.

That said, when you start from nothing and spend your entire career furiously climbing the corporate ladder to make something of yourself, getting canned can hurt almost as much as your wife saying she can’t stand to live with you anymore. Even more so when you realize you have only yourself to blame.

That happened decades ago, but I’ll never forget it. And while my wife did eventually come back, it wouldn’t be the last time I would suffer the pain and humiliation of being fired. In fact, I’ve been on both sides of that equation, more times than I care to think about. And I’ve learned a very important lesson through those experiences.

In just about every case I can think of, the termination was not only justified, it was the best thing that could have happened, both to me and to those I sent packing. The truth is, we all learned from the experience, took the feedback to heart, became better for it, and moved on to bigger and better things.

At his incredibly moving Stanford University commencement speech, Steve Jobs talked about the devastating loss of being ousted from Apple, an event that was precipitated by his toxic management style. "I didn't see it then," Jobs said, "but it turned out that getting fired from Apple was the best thing that could have ever happened to me.”

What followed was a period of soul-searching and transformation that led Jobs to the woman he would spend the rest of his life with. It also led to the founding and enormous success of Pixar. And it ultimately led to his return to Apple (AAPL) and what is undoubtedly the greatest turnaround story in the history of corporate America.

Jobs went on to say, “I'm pretty sure none of this would have happened if I hadn't been fired from Apple. It was awful-tasting medicine, but I guess the patient needed it. Sometimes life hits you in the head with a brick. Don't lose faith.”

Likewise, the first time I was fired ultimately led me to Silicon Valley, an IPO, and a thrilling career as a senior marketing executive. And the last time made me realize I was done with the corporate world. It led me to strike out on my own as a consultant and a writer, which is where I am to this day. And for that, I’m eternally grateful.

As it is with life, your career is a long journey without a well-defined destination. You depend on those major inflection points, those wakeup calls, those bricks to the head, to tell you that your current path isn’t right for you. That it needs correction. But it’s up to you to learn and grow from the experience. To use the opportunity to find a new path. A better path. 

Jobs put it this way: “You've got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it.”

Losing your job is a great loss. It’s humiliating and painful. And it’s not unusual, at least at first, to feel anger and resentment. To blame others for what happened to you. Just don’t let the process end there. Once you get past the pain and the rage, take a long, hard look in the mirror and be honest with yourself about what you see.

In time, you’ll look back and realize that, in losing something important to you, you gained something even more important to you: an opportunity to gain insight into yourself and to find a better path. A truer path. A path that leads to happiness and fulfillment.

As jazz great Miles Davis said, “When you hit a wrong note, it’s the next note that makes it good or bad.”

Steve Tobak is a management consultant, former senior executive, columnist and author of the upcoming book, “Real Leaders Don’t Follow." Tobak runs Silicon Valley-based Invisor Consulting where he advises executives and business leaders on strategic matters. Contact Tobak.