   public func stop() -> Completable {
     Completable.create { completable in
       self.queue.async {
-        self.stopLock.withWriteLock {
-          self.streamSubject.onCompleted()
-          self.cleanUpAndCloseSocket()
-
-          completable(.completed)
-        }
+        self.streamSubject.onCompleted()
+        self.cleanUpAndCloseSocket()
+
+        completable(.completed)
       }
       return Disposables.create()
     }

          }
        } catch let error as Socket.Error {
          self.streamSubject.onError(Error(msg: "Could not read from socket", cause: error))
          // No need to lock since we are currently trying to open the socket.
          self.cleanUpAndCloseSocket()
          return
        } catch {
          self.streamSubject.onNext(

          ]
        )

        if self.stopped {
          single(.error(Error(msg: "Connection stopped, " +
                                   "but trying to send a request with msg id \(msgid)")))
          return
        }

        guard let socket = self.socket else {
          single(.error(Error(msg: "Socket is invalid, " +
                                   "but trying to send a request with msg id \(msgid)")))
          return
        }

        if expectsReturnValue {
          self.singlesLock.withLock {
            self.singles[msgid] = single
          }
        }

        do {
          let writtenBytes = try socket.write(from: packed)
          if writtenBytes < packed.count {
            single(.error(Error(
              msg: "(Written) = \(writtenBytes) < \(packed.count) = " +
                   "(requested) for msg id: \(msgid)"
            )))

            return
          }
        } catch {
          self.streamSubject.onError(Error(
            msg: "Could not write to socket for msg id: \(msgid)", cause: error))

          single(.error(Error(
            msg: "Could not write to socket for msg id: \(msgid)", cause: error)))

          return
        }

        if !expectsReturnValue {
          single(.success(self.nilResponse(with: msgid)))
        }
      }

