It is assur to leave Shul during k’ri’as HaTorah. A passuk speaking harshly about “people who forsake HaShem” is said to be speaking about such people. If one needs to use the bathroom, one should wait (if physically possible) until the interval between aliyos. If there is a different urgent need, one may leave during that interval, if the need is indeed urgent, and if he has already heard k’ri’as HaTorah or will be returning immediately.
Shabbos Bulletin Parshas Vayigash 5779
About the Author: Lev Seltzer
Lev Seltzer has been a member of Beis Tefillah from just a short time after its founding. He currently manages the BTYA.org website, and can be found every morning in the BTYA "Vasikin Room" where he is the gabbai of the minyon.