We study the origin of the temperature-induced Mott transition in Ca2RuO4. As a method we use the local-density approximation+dynamical mean-field theory. We show the following. (i) The Mott transition is driven by the change in structure from long to short c-axis layered perovskite (L-Pbca to S-Pbca); it occurs together with orbital order, which follows, rather than produces, the structural transition. (ii) In the metallic L-Pbca phase the orbital polarization is ~0. (iii) In the insulating S-Pbca phase the lower energy orbital, ~xy, is full. (iv) The spin-flip and pair-hopping Coulomb terms reduce the effective masses in the metallic phase. Our results indicate that a similar scenario applies to Ca_{2-x}Sr_xRuO_4 (x<0.2). In the metallic x< 0.5 structures electrons are progressively transferred to the xz/yz bands with increasing x, however we find no orbital-selective Mott transition down to ~300 K.