EDIT:
Maybe someone can also help me my making the attached script work? As mentioned above OTA update failed if I added a simple webserver to the sketch. When I open the IP of the ESP8266 in a browser the served page runs a script which asks for data once per second. During an OTA update at some point one can see that there is no data coming anymore but the update process terminates with an error. With no browser window running the script it worked fine. I suspect it may be good if I could stop the server on the ESP but don't know how to do that.
I think the tested scenario could happen in a real application as well so I appreciate any help to solve this.
Thanks again, Bernd