shrank transmit window when writing, fixed a nil pointer when closing