Time-domain terahertz systems can face challenges due to systematic delay errors introduced by the employed delay mechanism, potentially leading to poor data quality. This article introduces a procedure to address these challenges by correcting low-frequency systematic errors that distort the acquired spectra and incorrectly diminish narrow absorption features. Our procedure solves an optimization problem aiming to find the corrected time-signal pairs that maximize the depth of narrow absorption features, and we highlight how the flexibility of the procedure, in principle, allows for correcting error profiles of arbitrary shape. We demonstrate the effectiveness of this approach through experiments using both simulated and experimentally recorded THz data, and the results show significant improvements in spectral accuracy. We believe this can pave the way for more reliable and precise terahertz spectroscopy measurements, enhancing its applications in various scientific and industrial fields.