Fixes issue with assert triggering when bytes to write to a message equals
zero.  Fixes issue with closing handle multiple time.s