In this paper, we propose a simple framework for closed-loop system identification: the stabilized output error method. Traditional closed-loop system identification methods rely on the linearity of the target system, and they require the identification of noise models or prior knowledge or identifiability of the feedback controllers to obtain unbiased estimates. But in many real-world applications, the noise dynamics and feedback controllers are complex and difficult to identify, and the nonlinearity may not be ignored. The proposed framework introduces a virtual controller that stabilizes the error between model prediction and the output of the target system. This enables us to apply the output error method, which gives unbiased estimates without depending on the noise model and is applicable to a wide range of models, including nonlinear systems, to closed-loop system identification problems. The paper describes the framework and gives the theoretical support and design guidelines for virtual controllers. Through numerical examples, we show the effectiveness of the proposed framework in various situations, which include identification of (a) linear gray box models, (b) systems in the presence of disturbances having realistic complexity, and (c) a nonlinear unstable system in a human-in-the-loop environment.