You can extend expiry of the session using

  {{ if eq .os "windows" -}}
  echo > %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.