You have to read the contract.
The above answer, and any follow up comments or emails is for informational purposes only and not meant as legal advice.
My advice is to contact an attorney to draft a buyer's rider to the contract. In the rider, certain provisions can be delineated so that you are afforded the utmost protection should the deal not close (including the return of your down payment). Good luck.
Most NYS Residential RE contracts allow for the forfeiture of the downpayment to serve as a remedy to a breach of contract. You should consult an attorney to review the contract to determine the extent of damages you may be liable for.