Lactones and Lactams
A molecule that contains a carboxyl group and a hydroxyl group can undergo an intramolecular esterification forming a cyclic ester called a lactone. A molecule with a carboxyl group and an amine can undergo intramolecular aminolysis to form a cyclic amide called a lactam.
Cyclization is often so favorable for γ- or δ- hydroxy acids, which form five- or six-membered lactones (and γ- or δ- amino acids that form five- or six-membered lactams) that the straight chain form may be difficult to isolate. For carboxylic acids with hydroxyl groups in other positions, though, the free energy change is not so favorable due to ring strain. In those cases equilibrium favors the straight chain form.