Programmaticaly remove a member from a group
The entity type interface (GroupInterface) has a removeMember method; all you need are the relevant entity objects:

if ($account = \Drupal\user\Entity\User::load($user_id)) {
  if ($group = \Drupal\group\Entity\Group::load($group_id)) {
    $group-&gt;removeMember($account);
  }
}