This might be the case in many other pieces of code, but as the wait is at the end of the loop, this will not happen, as cod2 runs on a frame-by-frame basis, and you cannot disconnect mid-frame.
Edit: above is true for checking for defined(), but not true for endon. Endon will work properly.
But like tally is saying, max variables might be an issue, especially on servers filled with players.