Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57047 Fix possible false test failure when the session gets closed before the message write can complete.