you could configure session timeouts via group policy, a great sample can be found here
Idle session limit
Specify the maximum amount of time that an active Remote Desktop Services
session can be idle (without user input) before the session is automatically
disconnected or ended. The user receives a warning two minutes before the
session is disconnected or ended, which allows the user to press a key or
move the mouse to keep the session active.
End a disconnected session
Specify the maximum amount of time that a disconnected user session is kept
active on the RD Session Host server. If you specify "Never," the user's
disconnected session is maintained for an unlimited time. When a session is
in a disconnected state, running programs are kept active even though the
user is no longer actively connected.
Both of these setting can be set in Computer Configuration or User Configuration.