The closing date is set during the negotiation phase, and is usually several weeks after the offer is formally accepted. On the closing date, the parties consummate the purchase contract, and ownership of the property is transferred to the buyer. In most jurisdictions ownership is officially transferred when the contract is registered at the cadastre, or, in most US states, at the office of the County Recorder of the county in which the property is located.
Several things happen during closing:
Closing in escrow usually occurs in the western half of the US states. A title company (rather than a lawyer) or other trusted party holds the money and the signed deed, and arranges for the transfer. This is primarily so that the seller can give up ownership of the property, and the buyer can hand over the payment, without both parties having to be present at the same time. Escrow ensures an orderly transaction, or if something goes wrong, an orderly termination of the agreement.
On the Eastern side of the US, settlement (as closing is called) takes place on a specified date and time during which all parties (usually including the agents involved) meet at a settlement company presided over or supervised by a lawyer. The transfer of money (in form of certified or wired funds) and the property takes place, and the deed is then recorded by the company.