If there is any disagreement the escrow company will not release it to either party. So if the seller says you shouldn't get the deposit back and you say you should, no one gets it till there is agreement.
Hope that helps
Since I am not licensed in your home state of MA, this really is a question for your buyer's agent or an attorney. However, the contingency you described sounds similar to a financing contingency that we use in our purchase and sale agreements in Georgia. Read your agreement closely to ensure that you are within the time limit for making notification to terminate your agreement (which typically must be in writing). With respect to disposition earnest money and/or down payment money, again check with your agent or a real estate attorney. Usually, there are provisions in the contract that define who is holding this money and how this money is dispersed. The holder of the money will most likely need to follow a specific procedure to notify the parties before your earnest money or down payment can be refunded. In some cases, all or part of the earnest money or down payment may not be refundable. Consult with your buyer's agent or a real estate attorney. Best wishes - Ted