Break out of loop if can't send data

Fixes #4046