216:1 On the final day of shiva, after the visitors depart from the mourner, all the things that were prohibited during the shiva become permitted. This is because the Talmud tells us that a part of the day is considered like the whole day. This rule excludes marital relations, which are prohibited the entire day, even in a darkened room. In our lands, where the practice is for visitors not to come on the seventh day, the mourner must wait until the time they usually come on the other days, i.e., after shul. If the last day of shiva was Shabbos, then Torah study is permitted after the mourner leaves shul in the morning.
216:2 We also say that part of the day is like the whole day when it comes to the last day of shloshim. Since there are no visitors coming then, he is immediately relieved of the rules of shloshim at daybreak. If the last day of shloshim fell on Shabbos, he is permitted to wash in hot water on Friday in honor of Shabbos, to wear Shabbos clothes, and to return to his regular seat in shul, but not to shave, as that restriction is more stringent.