A comprehensive analytical description is given of the longitudinal dynamics of a storage-ring free-electron laser in the presence of a finite light-electron beam temporal detuning. Closed analytical expressions for the main statistical parameters of the system (i.e., beam energy spread, intensity, centroid position, and r.m.s. value of the laser distribution) as a function of the detuning are provided. The transition between the stable "cw" regime and the unstable steady state is shown to be a Hopf bifurcation. This allows us to introduce a feedback procedure which suppresses the bifurcation and significantly improves the system stability. The critical value of the detuning above which the bifurcation occurs is analytically derived as a function of the electron energy and of the beam optics parameters. Results are compared to experiments and display good agreement. Comparisons with other theoretical models are also drawn.