Acquiring models of the environment belongs to the fundamental tasks of mobile robots. In the past, several researchers have focused on the problem of simultaneous localization and mapping (SLAM). Classical SLAM approaches are passive in the sense that they only process the perceived sensor data and do not influence the motion of the mobile robot. In this paper, we present a novel integrated approach that combines autonomous exploration with simultaneous localization and mapping. Our method uses a grid-based version of the FastSLAM algorithm and considers at each point in time actions to actively close loops during exploration. By re-entering already visited areas, the robot reduces its localization error and in this way learns more accurate maps. Experimental results presented in this paper illustrate the advantage of our method over previous approaches that lack the ability to actively close loops.