udp: fix occasional crash on shutdown