If the purchase agreement falls apart for a reason that’s listed as a contingency in your contract, you can get the money back. If you back out of the contract for some other reason, you risk losing the earnest money deposit.