Sometimes you can see the writing on the wall. Maybe you made a major mistake, or perhaps you fell out of favor with the wrong person. In many ways, the reason does not matter -- you simply know that you're in danger of getting fired.
Just because you know it's coming, however, does not mean you have to resign yourself to your fate. Instead, there are things you can do to change your situation. If you expect the ax is coming, the right move can actually save your job.
1. Talk to the boss
Schedule a meeting with your supervisor and address the fact that you believe there is some dissatisfaction with your performance. Ask for an action plan designed to bring your work back into compliance.
If the boss agrees, stick to the plan, and if possible exceed it. It's very hard to fire someone who has done everything you ask of them.
If your situation has become untenable and you don't believe your employer would be willing to consider letting you remedy the situation, get ahead of it. If you don't think your firing is imminent, make an effort to find a new job before losing your old one.
Also, ask yourself if avoiding the stigma of being fired is worth losing any severance or separation benefits your employer might offer. For example, how unused vacation days are handled may be different depending on the circumstances of your departure.
Voluntarily quitting is more or less breaking up with someone before they break up with you so you can say you were the one who left. There's a benefit to that, but you may have to make sacrifices to make it happen.
If you haven't already been fired then whatever offense or offenses you have committed are likely not that terrible. Because of that, your employer may be open to a mutual parting of the ways. You can ask for severance, other standard departure benefits, and an acknowledgment that you both agreed now was the time for you to move on.
If you handle things correctly, instead of being marched out with your possessions in a box, you might get a goodbye cake at a sendoff party. In many cases, if your employer wants you out, he or she will still be open to having it be a pleasant parting, because that's easier for everyone involved.
The last thing you want to do is negotiate your own exit when your employer hasn't actually thought about getting rid of you. But if the end is inevitable, or at least on the table, taking control of the situation can make something that has the potential to be awful a little bit better. You may still end up out of work, but having your departure go down as a layoff or a mutual parting makes you a more attractive candidate when you start looking for your next job.