The Gemara in Masechet Megila comments that when one rolls the Sefer Torah, he should do so “Mi’ba’hutz” – literally, “from the outside.” Numerous different interpretations have been offered to explain the Gemara’s comment, but the Ran (Rabbenu Nissim of Gerona, 1320-1376) explained that the scroll should be taken out of its case before being rolled. If the scroll is turned when it is still in the case, there is a risk that the parchment will be torn in the process, and the Gemara therefore requires removing the scroll from its case before it is turned. This explanation is cited by the Shulhan Aruch (Orah Haim 147:6), who writes that it is improper to roll the Sefer Torah before removing the scroll from its box.
The Kaf Ha’haim (Rav Yaakob Haim Sofer, Baghdad-Israel, 1870-1939) suggested that this Halacha applies only when the Torah needs to be rolled a significant amount, such as, for example, from that week’s Parasha to the reading for Rosh Hodesh. Clearly, the Kaf Ha’haim noted, Halacha does not require removing the scroll from the case each time the reader reaches the end of a column and needs to roll to the next column.
Regardless, the common practice today is to permit rolling the Sefer Torah inside the case, without removing the scroll. The Ish Masliah (Rav Masliah Mazuz, Tunisia, 1912-1971) suggested that this Halacha does not apply nowadays, when the scroll is securely fastened in the case and considerable effort is required to remove it from the case. In ancient times, the scroll could be easily removed, and thus removing the scroll before rolling it did not cause inconvenience to the congregation. Nowadays, however, this would be cumbersome and cause inconvenience, and so the Halacha does not apply. Moreover, the Ish Masliah adds, Sifreh Torah are crafted today in such a way that the rolling can be done safely with the scroll inside the case, and there is thus no concern that the parchment would tear.
Accordingly, as Hacham David Yosef writes in Halacha Berura, the accepted practice today is to roll the Sefer Torah without removing the scroll from the case.
The Shulhan Aruch (Orah Haim 147) writes that the reading of the Haftara should not commence until after the Sefer Torah is rolled. This Halacha is not so relevant today for Sepharadim, as we simply close the case and do not have to roll the Sefer Torah. Ashkenazim, however, have somebody roll the Sefer Torah after Hagbeha, and they must ensure not to begin the Haftara until the Torah is rolled.
Later (149), the Shulhan Aruch rules that even after the Torah reading, one should not leave the synagogue until the Sefer Torah is returned to the Hechal, as this is disrespectful to the Sefer Torah. The Rama (Rav Moshe Isserles, 1525-1572) limits this prohibition to a case where the majority of the congregation leaves; for individuals, however, there is no prohibition against leaving while the Sefer Torah is out of the Hechal. The Shulhan Aruch, however, does not draw this distinction, and indeed many Aharonim (including the Magen Abraham, Peri Hadash and Aruch Ha’shulhan) disagree, and maintain that even for an individual it is considered disrespectful to leave the synagogue while the Sefer Torah is out of the Hechal. Therefore, Hacham David Yosef writes in his Halacha Berura that even if one is unable to remain in the synagogue until the very end of the prayer service, such as if he needs to leave for work, he must at least remain until the Sefer Torah is returned to the Hechal. He adds that it is customary to escort the Sefer Torah as it is returned from the Teba to the Hechal.
Summary: Although in ancient times the Torah scroll was removed from its case when it was rolled, nowadays it is customary to turn the scroll without removing it from its case. One should not leave the synagogue while the Sefer Torah is out of the Hechal.