Deposit rights don’t depend on why you left
Yes. Your security deposit rights apply when you move out regardless of why you left, and leaving because of serious conditions does not forfeit your deposit. In fact, if you left because the landlord failed to maintain the home, that context may strengthen your position.
After you move out, the landlord generally must return your deposit, minus only lawful deductions like unpaid rent you actually owe or repairs for damage beyond normal wear and tear, and must provide an itemized statement within the required time — commonly 21 days. A landlord cannot lawfully keep your deposit to punish you for leaving over their failure to make repairs.
If the reason you moved was the landlord's neglect, be sure to document the unit's condition when you left, since that protects you from being blamed for damage that was really the landlord's responsibility.
If a landlord withholds your deposit after you moved out over habitability problems — especially by claiming you "broke the lease" — that may not be valid. A free, confidential review can help you understand your deposit rights and how to recover what you are owed.
This is general information about California tenant rights, not legal advice. Every situation is different.