Fix sample memory leak when no client is connected.