Stop server on ESP8266


Currently I’m working on a project with an ESP8266 module.
It’s running stand alone, I’m communicating and programming it with the arduino IDE using the ESP8266 library.(Link :

I’m starting the ESP as an AP, which displays a webpage. This is working.
Now, I want to visit this webpage with a mobile phone, and fill in a SSID and a password and let the ESP connect with a SSID which also works.

Now, I can’t shut down the server, running on the ESP. The server is started like this:

ESP8266WebServer server(80);

server.on("/", handleRoot);

Someone has a clue how to stop the server?

Kind regards,

Jan Paul