What I meant was that there are no restarts/shutdowns, but only automatic logoffs 2 hours after disconnecting from the remote desktop (on the computer, which I was connected to). That's all what happens.
Tried everything You proposed, but nothing helped. I'm still getting signed out. All I found is something in policies called "Force logoff when logon hours expire", but it also didn't help. Same with disabling scheduled tasks/going into safe mode.