It is better to quit than be fired.
I can’t tell you when or under what circumstances you should do this, each situation is different. However, you need to learn how to protect yourself and your career by walking away. If time will afford you the opportunity – be prepared.
Make sure you have packed your parachute properly before you jump:
Have your resume and social media presence updated
Have a list of potential employers you may want to work with
Established connections with people through social media
Stay current on job listings
There will be times when this may not be possible. Still, jump before you are pushed. Sadly, there is still a stigma attached to being terminated/fired, even by the horrible boss or organization.