Cal. Civ. Code § 1950.7
(c) The landlord may claim of the payment or deposit only those amounts as are reasonably necessary to remedy tenant defaults in the payment of rent, to repair damages to the premises caused by the tenant, or to clean the premises upon termination of the tenancy, if the payment or deposit is made for any or all of those specific purposes.
(d) Upon termination of the landlord’s interest in the unit in question, whether by sale, assignment, death, appointment of receiver or otherwise, the landlord or the landlord’s agent shall, within a reasonable time, do one of the following acts, either of which shall relieve the landlord of further liability with respect to the payment or deposit: