Company not returning original documents and asking for 50% of salary to resign

Good evening, I have been working for a private school since last 3 months. They took my original documents at the time of joining. I have acknowledgement. Also I have signed a contract in which my term period is till may 2025. Its also mentioned in contract that in emergency I can leave the job by giving a notice period of 30 days. I got selected in ph.d programm and for that I have to leave my job. But they are denying and telling me it will not be considered as emergency , only marriage or govt job is considered as emergency. But it wasn't mention in the verbal or written agreement. I have to leave in december but as soon as I got information I informed them almost 2 months earlier but they are telling me I can't leave without serving my term. They told me to return my whole salary and through negotiation I agreed for 50% of salary which is 20k . They also have my 1 month salary and they are basically telling me to work without pay for my notice period. But it feels quite injustice to me. Please guide.