IIRC, it was his last year of contract.
Bayern didn't have the choice since he refused to renew it. They tried, he refused because of a lower salary than what was offered to him elsewhere.
So instead of pulling a Klopp and letting him go for free next year, they preferred to sell him...