As soon as escrow opens up on a property, the buyer has to wire over their deposit money.
The deposit is typically 3% of the purchase price of the home.
This 3% is held by the escrow company.
They hold on to the money just in case the buyer breaches the contract and the buyer and seller go to an arbitrator to decide who the money should be awarded to.
If the buyer backs out of the deal because of one of their contingencies (inspection, appraisal, loan), and they are within their contingency period, then the buyer gets their deposit back without any problems.
But if the buyer backs out of the deal, and all the contingencies have already been removed, that's when the seller can come after the buyer's deposit for damages they incurred.
An arbitrator will hear both sides of the story and ultimately decide who gets to keep the deposit money.