You can extend expiry of the session using {{ if eq .os "windows" -}} # cmd echo > %agentdir%\.hold # powershell $null > $env:agentdir\.hold {{- else -}} touch $agentdir/.hold {{- end }} The expiry time is equal to the modification time of the .hold file with the expiry duration (%v) added. To prevent the agent from exiting after the last session is gone, also use the above command in any shell.