So, no matter how dedicated your usual play group is, or how awesome your game can be, at some point or another as a GM you are going to have to deal with the fact that Players, and Player Characters, come and go. When that happens, you're left holding the ball so to speak. How do you handle that that one player isn't around today? Are they coming back? What about that new player that is joining your game, how do you add them to the group properly? What it comes down to in the end is a strange juggling act that when done right merely works with more credit going to the Player than you, and done wrong will come across as forced and bad.
Two Types of Leaving
The first aspect of dealing with someone leaving is to know what kind of leaving you are dealing with. Is this a temporary break from the game? A player can't make this one session, but will be back for the next, or at least will be back a couple of sessions down the line? Or is the player actually leaving the game for good?
If it is the latter, don't take it too hard. Unless the Player is specifically citing something like boredom there probably is more to it than just your game being bad. Real life has a nasty habit of getting in the way, and if the player is younger, odds are they're in a job that is going to be moving shifts around. You can't really expect a few hours of fun with friends to compete with "I can pay rent and eat this month" after all. Either way, if you're unsure about why someone is leaving simply ask. Just don't make the mistake of trying to make drastic sweeping changes to keep someone from going. It never works out as well as you'd want.
Gone For a Session or Two
A player missing for a session or two is probably actually harder to handle than someone just flat out leaving. The problem is you need to figure out how to handle their character while it is gone. Is it still with the group? If so, is someone controlling it? What about consequences, do they befall the character? If there are consequences, can it also help out?
Different groups have different ways of dealing with this, and depending on the group they work. Personally, I don't think someone should control anyone's character but them. That is unless the player themself comes to you and asks if someone can control them. At which point they need to be informed that all results of that control are permanent. "Tagging along, but not there" is another common one, and works well in instances when the party is in a situation that someone can't simply vanish from. Usually when doing this I'd recommend the person is completely out of reach, but if the party gets wiped then they're gone too.
If the party isn't doing something super important, or where they're confined you can also just have the PC be somewhere else handling personal business. This can make re-integrating them tricky, since the group could be in something dire when they come back. But at least it explains everything quite nicely.
Finally, you may just have to call session. It sucks to do it, especially for just one player missing, and most GMs can simply work around it. Sometimes though there is just no way around it. The person who is going to miss the session is absolutely vital to the next session. Decisions they make possibly having very long and laster repercussions through out the rest of the story. In that instance, it may just be better to call for no game the next week. Go see a movie instead, or do a one shot of something else.
If the player is leaving forever, than handling them becomes much easier. You can NPC out the player for the rest of whatever dire thing is currently going on and then have them leave. You can kill them. They can just poof. You can always ask the player how they want the character to leave the game, and work to do that.
However you do it, make sure that any key plot items that affect other members the character had on them get passed on somehow, or otherwise accounted for. It may take some work in re-introducing some things, but it's no fair penalizing the rest of the group because the person with most of the answers suddenly has to work during game hours.
Entering the Game
Depending on the structure of your game, adding a new person can be really hard, or really easy. In any game involving a military or other structure of some sort, where an authoritative body has an ability to give the Players orders or direct them, a new member can simply be assigned to the team. Replacing a dead member, or just adding another number to the group. The reasons for it can be more simply thought up, and as far as the original group is concerned it's just business as usual.
Without that, you need to reach a bit more. I mean, you could just have the person be stumbled onto, mutual goals, meet up, and yay there is a new group, but that gets suspicious around the fourth or fifth time it happens. It was always off putting to me how, in an old D&D game, we'd be the first people to be exploring some ancient dungeon in centuries, then turn a corner and find some other adventurer whose group had just been wiped out just sitting there. Again, once it is strange but ok, but two, three, four more times? Each from different groups at different depths in the dungeon? What, did the place just suddenly have an open weekend that every adventurer and their mom just have to show up for?
If there is no authority figure over the group, you need to work harder and think faster to get someone new into the group. You can just have them show up, and the players may allow them in, but even that is kind of weird. What connection to the story does this new person have? Why are they here? Most importantly, why are they so willing to risk life and limb fighting alongside a bunch of heavily armed people they've never met before?
There really is no easy answer to this, but if a player is ok with it, sometimes bringing the new person in with a connection to an established character can work wonders. It also gets weird the fifth time through sure, but for the first couple, it gives a reason to be there, and for the group to trust them.
Hopefully this helps a little the next time you have to deal with someone joining or leaving your game.