Enzymatic oligonucleotide synthesis methods based on the template-independent polymerase terminal deoxynucleotidyl transferase (TdT) promise to enable the de novo synthesis of long oligonucleotides under mild, aqueous conditions. Intermediates with a 3' terminal structure (hairpins) will inevitably arise during synthesis, but TdT has poor activity on these structured substrates, limiting its usefulness for oligonucleotide synthesis. Here, we described two parallel efforts to improve the activity of TdT on hairpins: (1) optimization of the concentrations of the divalent cation cofactors and (2) engineering TdT for enhanced thermostability, enabling reactions at elevated temperatures. By combining both of these improvements, we obtained a ~10-fold increase in the elongation rate of a guanine-cytosine hairpin.