How long are you supposed to take anti anxiety medication and can it stop your abnormal anxiety for good?

I’d like to know generally how anti anxiety medications work, how long one is supposed to take them, and how a person or a doctor knows when is the right time to stop the medication.
If the anxiety is due to a chemical imbalance, does that mean the meds must be taken forever?

What anxiety medication do you take and how did you first know you needed medication?

What anxiety medication do you take and how did you first know you needed medication?