When you are done working on your VM and need to disconnect you first need to logout from RStudio.
There is an on/off button at the top of the RStudio window (shown with an arrow pointing at a red circle)
Push the off button and you should get this:
You can then close the browser tab for RStudio. DO NOT close the tab without pushing the off button first!
type exit
at the prompt.
You will prompted to remove the Rstudio session
Do you want to remove Rstudio session as well? [yY/nN]
-type y
.
You should see this:
Close the tab or exit the browser and you are done.
If you realise at this point that you forgot to do something and want to log back in, just push the Connect button.