In a terminal app on Android, enter (requires root access) :
su
am stop-user USER_ID
E.g. For a Guest user, its USER_ID
in my device is 11
so the command would be am stop-user 11
.
am stop-user
doesn't process multiple input so you've to execute the command for every secondary user which you want to pause.
This is bit different from restarting the device. If you check am
's usage you would see,
am stop-user: stop execution of USER_ID, not allowing it to run any code until a later explicit start or switch to it.
As said, it simply pauses all the activities associated to that user account, so whenever an explicit start or switch is provided your session would resume rather than starting from scratch.
For confirmation that the user indeed has paused or is not running, see my answer for How to find out currently running user name/ID from ADB?
Briefly, pm list users
or dumpsys activity
would tell you whether the user is RUNNING
or SHUTDOWN
. The latter command is better. If the user-session is indeed put on halt by am stop-user
, you would see mState=SHUTDOWN
for that user. However, if the user hasn't been activated even once since the reboot, you wouldn't see any of its entry.