What I see in your code is: gsmAccess.begin(); which is blocking.
I got the GSM module restarting after a few attempts using gsm.begin(pin, restart, sync) method with sync parameter set to false.
Here I shared a non blocking InitGSM function that might help: Arduino GSM Shield not responding? - Arduino GSM Shield - Arduino Forum
HTH,
Cabbi