iOS 13.0 and later
Unfortunately due to a restriction imposed by Apple in iOS 13.0 and later, it is no longer possible to keep a background connection open for longer than 30 seconds.
Versions of iOS earlier than 13.0
Please ensure that Background App Refresh is enabled in iOS' Settings, in the General section. This will allow you to switch apps without being immediately disconnected.
Note: due to an Apple limitation, the connection will still be closed after a couple of minutes when the VNC Viewer app is in the background.