Mobile connectivity can break when WiFi goes out of reach
Currently, Android works in a way where it disconnects from mobile internet when you are on WiFi network. By doing so it saves battery because if on WiFi you wont be using the data connection anyway.

There is an option in Settings - Developer options where you can switch on "Mobile data always active" which should basically do what you ask. Keep the data connection on and on WiFi disconnect it will already be on and ready.

Note that this may drain your battery faster.