The California Residential Purchase Agreement allows for many contingencies on the purchase of real estate. For example, depending on the contract, there can be a loan contingency (if the buyer is not able to get a loan, they are not obligated to purchase the property), appraisal contingency (similarly, if the property does not appraise for the purchase price, the buyer is not obligated to purchase the property), disclosure contingencies (various disclosures the seller provides to the buyer), inspection contingencies, etc.
The "default" time period for these contingencies is generally 17 days from the date both seller and buyer agree to the terms of the purchase, assuming the seller has provided everything contractually required in the time periods required by the contract. IF anytime within the 17 day contingency period (again, 17 days is the default, it can be changed contractually), the buyer changes his/her mind he/she can cancel the contract and receive a return of their deposit.
Let me know if you have any additional questions.