How do struggling companies decide who to lay off in a recession? originally appeared on Quora: The best answer to any question.

Answer by Auren Hoffman, CEO of LiveRamp, on Quora:

Companies always need to retain their top performers. When a company is struggling it is even harder to retain top performers. Here are some rules of things to do and not do when your company is falling on hard times:

Never, ever, lay off your high performers
This may seem obvious (why would any company ask its best people to leave?) but countless companies tell their highest performing people to go. This is really really bad. If a company lays off just a few high performers, the remaining high performers will become fearful of their job and start looking for work. And once your high performers are looking for jobs, they are not going to be focused on the company. A company that is experiencing hard times and distress needs all its amazing people focused on making the company better.

Do the layoffs quickly and all at once
If you do the layoffs in waves, good people will become fearful of their jobs and start looking for work. So lay off everyone at once and tell everyone there will not be another layoff (and make sure this is a true statement). That means you’ll likely need to layoff MORE people that you think you need to (just to be on the safe side of never having to do a layoff again).

Always choose who you lay off
Never allow employees to self-select to be laid off. If you do that, many of your best people may select to be laid off. Programs like “early retirement” are generally bad as you will have many terrific people opt to leave the company. When your company is in crisis, you cannot afford to have your top people leave. You need them in the company and engaged.

Tell everyone you are laying off the low performers — and actually do that
If you have to do a layoff, you want to lay off the lowest performers. Depending on how big the layoff is, there may be a lot of good people amongst these “low performers,” but at least it will not be your very best people. Always do everything to keep your best people.

One thing many companies do wrong is that they message that they are laying off people and using some sort of methodology (like seniority, geography, etc.) to decide who stays and who leaves. This is really worrisome because the very best people can get caught in the methodology. For instance, if you fire just your newest hires, you will be firing some super talented people with them. Also, the high performers who did not get fired will think that they COULD get fired and they may start looking for other jobs.

Instead, send the message to the company that who was laid off was determined by how people perform. Let them know it is not an exact science and that you may have made some Type 1 and Type 2 errors, but at least that was the intention of the layoff methodology. This performance-based layoff may not make the people being laid off feel as good, but it will make the people who are staying feel more secure about their jobs (especially your highest performers).

Take care of the people you lay off
Getting laid off is really hard on people. Often it can massively change someone’s life for the worse. You have a responsibility to these people to take care of them, give them a fair severance, potentially help pay for education and training, potentially pay for extended health coverage, and go out of your way to help them find future employment.

Do everything you can to prevent layoffs in the first place
The best thing you can do is to never have to do a layoff. Even the best layoffs are demoralizing. Instead, be very smart about who you hire and don’t over-hire. Be realistic about the future and make smarter bets. Be smart about the future so you can take advantage of a downturn and not be taken advantage of in a downturn. Remember Warren Buffett’s famous quote: “Be fearful when others are greedy and be greedy when others are fearful.”

This question originally appeared on Quora. Ask a question, get a great answer. Learn from experts and access insider knowledge. You can follow Quora on Twitter, Facebook, and Google+. More questions: