WiFi.status() hangs / resets board
I think it might be a problem with the code you are using, prior to version 2.2.0 of the "ESP Core" the first block of code worked, since only the second version works.

It seems that you can get around it by rather than doing this:

 WiFi.begin(ssid, password); // connect to the network
 while (WiFi.status() != WL_CONNECTED) 
 {
     delay(500);
 }


You should do this:

if (WiFi.status() != WL_CONNECTED) 
{
     WiFi.begin(ssid, password); // connect to the network
     delay (500);
}


Does that look it might be a likely cause?

Sources
 1  2