No, eraseCredentials()
is meant for erasing sensitive data before persisting a token — be it serialization or a database.
To logout a user programmatically, you can use this:
$this->get('security.context')->setToken(null);
$this->get('request')->getSession()->invalidate();