Quoted By:
In USUM, there's a sidequest about a Pokemon center nurse who has to go through and release all of an old man's Pokemon because he died, but one of them refuses to go. You have to find his living relatives and deliver the Pokemon to them.
In the anime, Pokemon can come out of their Pokeballs freely so they either just wait for someone to formally release them or just hang out in the place their master died. In the Orange Islands there was a sailor whose ghost Pokemon decided to haunt the ruins of his sunken ship and stop people from looting it. There was also an episode about a Ninetales who waited hundreds of years for its master to return, until Brock finally explained that its master was dead and released it back into the wild.