burn-one-s-bridges

Even if you are dismissed from a job in the worst way, take care to not burn your bridges with unseemly comments on the way out, since you never know who you will meet again.

Origin

Originally in military sense of intentionally cutting off one's own retreat (burning a bridge one has crossed) to commit oneself to a course of action, later used primarily to mean “alienate former friends”.