added some cleanup code on child exit to ensure friendly shutdown of sockets