Fix dataloss race when sending commands.