The basic goal of every Pokémon Trainer is right there in the title: they catch Pokémon, train them, and have them compete with other Pokémon. Many Trainers go on long journeys across their region or even the world as a part of this goal, catching many Pokémon along the way.
Of course, this leaves fans with the obvious question of what happens to all of a Trainer's Pokémon once their journey is over. Naturally, Trainers are responsible for taking care of them while they're on the road, but that obligation doesn't simply disappear once they're done traveling -- they're still responsible for the fate of their Pokémon. This could be especially troublesome for a trainer like Ash, who has caught dozens of Pokémon throughout the anime, but there are several options available to him.
After their journey, what can a trainer do with their Pokémon?
As most players of the games can confirm, simply releasing Pokémon once they've completed the game is a non-starter. If the day comes when they consider themselves done with a save file, they'll either transfer the relevant Pokémon to another game or simply leave them in the Pokémon Storage System. Since the games allow Trainers to store their Pokémon as electronic data, there's no need to worry about taking care of them.
Unfortunately, anime Trainers don't have the same luxury of storing their Pokémon on a PC. Any Pokémon they catch beyond the limited six they're allowed to have must be sent to someone they trust to look after them. In Ash's case, he leaves his Pokémon with Professor Oak. Other Trainers will have their extra Pokémon sent home for their families take care of. When their journey ends, they can likely visit these Pokémon whenever they want.
If they wanted to, Trainers could also release their Pokémon. Ash has done this a few times and it doesn't seem as though living in captivity affects their ability to survive in the wilderness. This can be done if the Trainer is either about to pass away or simply can't care for their Pokémon anymore. If the Pokémon isn't properly released, however, they could end up waiting indefinitely for their Trainer to return. An extreme example of this came up in Episode 232, "Just Waiting On a Friend;" a Ninetales had been waiting over two hundred years for its master to return until Brock broke its antiquated Poké Ball and set it free. Pokémon can be very loyal and can have trouble moving on if something happens to their Trainers.
Can a Trainer retain control of their Pokémon after a trip?
Trainers can also continue to raise their Pokémon themselves, which is a straightforward method. It's crucial to realize that not every Trainer manages to capture dozens of Pokémon on their trip. Only Trainers who are truly dedicated to becoming Pokémon Masters fill their teams with six Pokémon (with potentially a few more on the side). Most Trainers will go as far as they believe is necessary before declaring their goal complete. They can then spend the rest of their days quietly with the Pokémon they've bonded with along the route. If a Trainer can care for their Pokémon while on the go, doing so from the comfort of their own home should be much easier.
If a Trainer does end up catching more Pokémon than they could possibly care for on their own, they could always send them to be cared for by a professor. With Trainers like Goh who are constantly catching Pokémon, having them sent to a professor as new specimens is ideal for all parties involved. It allows the researchers to study a species while the Trainers can focus on the fun of raising a select few Pokémon they've become particularly close with. If they want to see some of their older Pokémon, that's okay, too.
The important thing is for the Trainer to make sure that their Pokémon end up in the right place once they're done journeying together. Whether they raise the Pokémon themselves, entrust them with someone who can, or release them, they have to be sure it's what everyone wants. Again, Pokémon are friends for life, so wherever they go, the Trainer will hopefully be able to meet them again.