>>53664240An anime episode showed that when criminals (such as poachers) are arrested, their Pokemon are confiscated and returned to the wild.
So presumably something similar happens here. The abusive trainer goes to jail, and the Pokemon gets returned to the wild.