This can be done in the Window RDP server with Group Policy:
https://serverspace.io/support/help/setting-timeouts-for-rdp-sessions/