Unless you exercise one of the contingencies in your executed offer contract (ex: mortgage, inspection, radon, pest, etc) and could prove this with legit paperwork, chances are you will lose your deposit. That said, try consulting an RE attorney to quickly review your offer contract and tell you what your options are. We have recommendations if you need it:
The first step in buying a home in MA is making an offer, with a good faith deposit. Once it is accepted, and both parties sign, there is usually a 10 day period for inspections and other contingencies. Then the P&S is signed, and a further deposit is made. Both of these documents (accepted offer and P&S) are contracts, so you should consult with a real estate atttorney if you have signed a P&S and want to cancel. If you are working with a real estate agent, talk to your agent also. Good luck to you.