Staying in a company where you're not wanted is a miserable experience. The company will do anything to make you leave. Plus, it weakens companies and makes for a poor general worker experience.
What should be done instead is mandate generous severance packages that increase with tenure. But give companies a clear path to fire people when they don't want to employ them anymore.