Check out example codes for "arduino client disconnect". It will help you in understanding the concepts better.

Code Example 1

WiFiClient client;

WiFi.begin(ssid, pass);
delay(4000);	//Allow connection to be established

client.connect(IP, port_number);	//Connect to server

client.stop()			//Disconnect

Learn ReactJs, React Native from akashmittal.com