Gain recovery dynamics of a terahertz quantum cascade laser