Marshall Goldsmith has come up with interesting matrix on resignation while managing your reputation. There are four quadrants.
Vertical axis talks about performer vs. non- performer- either you are a high performer in organisation or your performance is declining and you are in non-performer zone.
Horizontal axis talks about you resigning on your own or someone else asks you to resign.
Ideal situation is when you are a high performer and you want to quit. You can look forward to a better career, while worst situation is when you are not performing and others are aware of it and you are asked to go.
This brings us to other two interesting situations.
You may be a high performer, yet may be asked to go. Possible reasons for this could be your superior sees you as a threat and may use office politics to ensure your exit or due to mergers and acquisitions (most of the mergers are acquisitions) your role has become surplus or redundant. You need to keep your antenna up to catch what is happening in organisation- office politics, mergers, reorganisation etc. so that you can plan your exit before you are asked to go, this will keep your self-confidence up when you quit.
You may be a low performer and decide to resign on your own. Here while few in current organisation may be aware of your low performance, the outside market is not aware of it, you can take advantage of this time gap i.e. get another job while you are still on rolls of current organisation. But you need act swiftly, because window of opportunity will close quickly.