[server] ensure to break out of while loop and close() UDP socket before returning