“We’re sorry, but you’re not working out here.”

If you’ve ever heard those words, you know that they’re code for “you’re fired.” Losing your job is never fun. In fact, it might feel like one of the worst things to ever happen to you.

That’s not an exaggeration. According to a research review from the University of East Anglia and the What Works Center for Wellbeing, getting fired from your job can have more lasting adverse effects than losing a loved one or getting a divorce.

“To have meaning in your life in this society means to be working, contributing, and to have that status,” said Tricia Curmi of the What Works Center for Wellbeing, an independent agency set up by the UK government.

Curmi’s team attempted to assess how different life events affected mental health, self-esteem, and satisfaction with life.

“After someone loses a partner, [well-being will] take a big dip and then, on average, it’ll get back to previous levels,” Curmi said. “But with unemployment, we just don’t see that happening.”

When you’re fired, you get a big, glaring hole on your resume, and the jarring effect of the sudden loss of employment can quickly disturb other areas of your life. However, it’s not necessarily the end of the world. With a bit of work, you can turn your unemployment into something positive—provided that you take the right steps.

First, try to assess why you lost your job.

You might have been fired without legitimate cause, but if you simply didn’t live up to your employer’s expectations, your first job (pardon the pun) is to determine what you could have done differently.

This is for your personal benefit, by the way. If you lost your job because you weren’t doing the work, you’d need to reassess your career. Your termination could even end up propelling you in the right direction.

Ask yourself whether you enjoyed the work environment and office culture. Determine your strengths as an employee, then think about any contacts from your previous jobs that might prove useful in the future. If you were laid off, ask your former employer if they’d be willing to provide a reference.

Whatever you do, don’t get angry. You won’t benefit from a last-second blowout with your former boss and co-workers (even though that might feel great).

Take a few days off, but realize that you’ve got a new job.

Your new job: job searching.

To quickly find a new position, you’ll need to start working eight hour days immediately. Treat it as an actual occupation and use the opportunity to develop your self-discipline.

Start by updating your resumé, but don’t write “fired” or “terminated” anywhere. If a job interviewer asks why you left, be honest, but you should try to move the conversation towards your accomplishments with your previous employer.

If you’re having trouble landing a new job, try volunteering. Charity work can look great on a resumé, and it can help you maintain a positive attitude after a sour termination. Make as many contacts as possible, and don’t be shy about telling them that you’re looking for work.

While you may feel humiliated or worthless at first, the truth is that your termination opens up an incredible set of opportunities. It’s practically impossible not to take the firing personally, but the experience will help you grow a thicker skin—and, hopefully, point you towards a more rewarding career.