This depends on whether an agent is a part of groups for which availability is managed centrally by admins ( can be configured under Admin-> Groups)
Case 2- Agent's availability is centrally managed.
If an agent is a part of one or more groups where availability is managed centrally by Admins, the agent's availability prior to logging out is considered for automatic routing.
For example, say Agent A and Agent B are part of groups where availability is managed centrally by admins. Agent A's status is available when they log out. Agent B's status is unavailable when they log out. Tickets will continue being assigned to agent A since they were available at the time of log out.