[WebConnection] Fix race condition between Close and BeginWrite (#4693)