When accessing a virtual machine, the connection is lost in TeamViewer upon closing the remote desk

Hi there,

When accessing a virtual machine, the connection is lost in TeamViewer upon closing the remote desktop. How can such issues be resolved?