Synthesis of macrocyclic esters by catalytic cyclization