Fixed a bug when the connection was closed before async write was finished
Corrected the implementation of the Close event in the BPSocketAdapter