To avoid getting stuck in a config mode if there is any temporary down time in the wifi connection I use the time out facility to alternate between wifimanager mode and doing a normal connect.
wifiManager.setConfigPortalTimeout(180);
wifiManager.autoConnect(WM_NAME, WM_PASSWORD);
That has all worked well. However, I have discovered that the wifimanager timeout leaves the AP mode active so that one can get into a condition where it timeouts, reconnects normally and leaves the AP network active. This persists until the device is reset and with multiple devices one can end up with lots of extra spurious AP points.
I have now changed the autoconnect to
if(!wifiManager.autoConnect(WM_NAME, WM_PASSWORD)) WiFi.mode(WIFI_STA);
Does that make sense or is there a better way?