Yes, in most places you can exit early, but the cost depends on which of three situations you're in, so start by rereading your contract and checking local tenancy law. Some jurisdictions grant tenants a statutory right to terminate any lease with a set notice period, often in the one-to-three-month range, regardless of what the contract says; in those countries, early exit is routine and penalty-free beyond serving proper notice.
Contracts themselves often contain the answer: a break clause allowing exit after a minimum period with notice, or a defined early termination penalty, commonly in the neighborhood of one or two months' rent, which functions as a buy-out price.
Whatever applies, the process matters: give notice in writing with proof of delivery, in the form and timing the contract requires, and get any negotiated exit deal documented and signed, including the deposit's treatment.