If you’re on Xbox: Settings > Network Settings > Test NAT Type > Wait until the ‘GTA is ready’ notification / Wait up to 3 seconds if it doesn’t pop up > Go back to GTA > Wait for about ten seconds, and everyone will ‘leave’.
Worth noting too that when you perform a NAT test, that's pretty much you in a solo public session until you restart your xBox, so joining friends or having friends join you can be problematic. It's a great way of doing stuff solo without the hassle of other players but for the times you want to play with friends, I wouldn't advise it. You can usually tell though, that when you start getting invites to missions, Heists and so on from other players, it's a sign that your session is 'Open' so is likely to have others join it. Usually when that happens, it enables you to join other sessions too but NOT perform the NAT test again until you restart your xBox.