Strong-field few-cycle terahertz (THz) pulses are an invaluable tool for engineering highly nonequilibrium states of matter. A scheme is proposed to generate quasi-half-cycle GV/m-scale THz pulses with a multikilohertz repetition rate. It makes use of coherent spontaneous emission from a prebunched electron beam traversing an optimally tapered undulator. The scheme is the further development of the slippage control in free-electron lasers [T. Tanaka, Phys. Rev. Lett. 114, 044801 (2015)]. An explicit condition for the spectral amplitude of undulator radiation and a phase condition for the electron density distribution, required for the generation of desired pulses, are presented. The amplitude condition is met by proper undulator tapering, and a generic optimal undulator profile is found analytically. In order to meet the phase condition, the distance between the adjacent bunches is varied according to the instantaneous resonant undulator wavelength. A 3D analytical theory is complemented by a detailed numerical study based on a direct solution to the 3D wave equation.