Take the write lock on a connection in the destructor.