I think I read a similar thread a while ago where @mdma suggested as workaround to put the device into Listening mode (WiFi.listen()) to clean up the sockets and "immediately" after that finish listening via WiFi.listen(false).
And he'll be looking into a better solution.
I only hope I understood this right tho' ![]()