Analysis of a stochastic approximation algorithm for computing quasi-stationary distributions