Don't attempt to write if the connection is closed.