socket: Implement proper shutdown