What if I want to terminate the Work Permit midway?

Good morning, all those experts, immigration lawyers here.
I was wondering about a hypothetical situation where in an expat comes to a point of terminating the work permit midway and the contract with his employer has a limited option.

I would like an expert opinion which discusses what is what and why from different angles. I had come very close to this about a year ago.

A work permit is not cheap in Tanzania considering the money, time and effort invested in getting one. If an employee wants employment contract to be terminated before the period then it is always better to solve this issue amicably. If you wish to take up an employment in different company you would require a NO OBJECTION CERTIFICATE from the past company/ employer to apply for a new permit with your new employer. If you do not wish to continue with any job in Tanzania, just terminate the contract and leave. But this act would be really unfair to the company considering the money invested to get a work permit. So it is reasonable to bear some % of the permit and travel ticket. It all depends again in the employment contract terms and conditions.