Hymsan, the script your using won't detect when Gmod 'locks', or an error pops up related to the server that expects a 'click' of a button.
The only way the script works is if the window closes on its own.
There was an application (free) that you could train to look for specified windows and click 'whatever button' was needed to have Gmod shut down.
I don't remember it's name. If Gmod server actually pops up an error message, that would probably help you. Use google to look for it.
Another Windows application, which I remember as actually causing lag on some friends servers, would actually monitor the port that your game server runs on and, if it couldn't connect every few minutes, would shut it down and restart it.
That was 2-3 years ago, you might find it and it not be laggy anymore.