Regulation of cyclization for the stereoselective synthesis of substituted tetrahydrofurans and tetrahydrooxepines.