Please help or guide regarding my deposit amount

I have stayed in a room where the owner mentioned in contract to stay for 6 months. But, due to unforeseen circumstances in my job, I had to leave the room before the contract ends. Now the owner of the room is not returning my deposit amount. Is it legal? As a tenant can I do anything to get my deposit back?

You are liable for the full six months of rent
They are entitled to keep the deposit.
They may chase you for the outstanding amount too