Earnest money also called hand money is a good faith deposit made by the buyer in a purchase transaction. Earnest money shows the seller that the buyer is serious and willing to put money at risk in exchange for the seller taking the property off the market while the sale is pending.
When there is a real estate broker involved the money is held in the escrow account of the brokerage. In FSBO transactions [for sale by owner] the buyer often gives the money directly to the seller. Alternatively, the money may be held by an attorney or other escrow agent.
Hopefully the parties have signed a sales agreement which clearly sets out the terms of a default and under what circumstances the seller may keep the earnest money. When the buyer defaults on the agreement, one option the seller has is to keep the earnest money. Another option is to sue the buyer for specific performance and force the buyer to close.
So, if the buyer defaults, there should be no expectation that the seller will release earnest money. BTW - changing your mind about the purchase is considered default. ;)
Now, if the buyer did not default and the earnest money is in the hands of a third party escrow agent, say the real estate broker, an attorney or other, then that party can read the terms of the contract and release the deposit without the consent of the seller. An escrow agent will only do this if the terms are crystal clear. Otherwise the deposit will sit in escrow until the parties resolve their differences.
If the buyer was foolish enough to give the earnest money directly to the seller and the buyer did not default under the terms of the contract and the seller refuses to release the earnest money, then the buyer will likely have to hire an attorney and sue - or at least threaten to sue.
The worst case I have ever seen was a transaction in which the buyer gave the seller the entire purchase price of $100,000 based upon a few notes written on the edge of a survey map which they all signed. The buyers were from out of town, looking for land, fell in love with a parcel owned by a man who met their expectations of an old fashioned nice guy. The seller created such an impression and a sense of urgency - there were other interested parties, etc. - that the buyers whipped out their checkbook and BOOM, there went $100,000.
This "nice guy" drove 2 hours and arrived at my office a few minutes past five, unannounced, to order the title work. He told the buyers he would take care of everything. I truly believe he wanted someone who didn't know him and he wanted to be the one to place the order, thinking he would control the outcome. I explained that the title insurance was being issued for the benefit of the buyer and that we would keep him in the loop but that we would be communicating with the buyer and reporting our findings directly to the buyer.
As you can guess, the seller wasn't who they thought he was. He and his wife had all sorts of financial problems and I think they started spending that $100,000 as soon as they had it in their hot little hands. What we found in title caused the buyer to NOT purchase the parcel. At my recommendation, they hired an attorney - in fact they ended up working with two attorneys and after a couple of years, I did end up testifying in court on their behalf. I don't know if they ever recovered all of that deposit.
So, as you can see, be careful about earnest money. Take seriously your obligations under the contract, think about how and if you have a chance of recouping the deposit if the transaction does not close. If you do not understand the terms of the sales contract, seek the advice of a good real estate attorney.