It will stay on as long as your computer is on and the connection isn't interrupted. That's why it is important to get a VPN service that offers a kill switch and set it on the system level. In that case, if your connection goes down it won't leak any of your data. I personally use NordVPN and you can set it to connect when your computer is turned on. Also, it has a kill switch.