     @IBAction func disconnect(sender: AnyObject) {
         if let room = room, let uuid = room.uuid {
             logMessage(messageText: "Attempting to disconnect from room \(room.name)")
+            userInitiatedDisconnect = true
             performEndCallAction(uuid: uuid)
         }
     }

    
    func room(_ room: TVIRoom, didDisconnectWithError error: Error?) {
        logMessage(messageText: "Disconncted from room \(room.name), error = \(String(describing: error))")
        
        self.cleanupRemoteParticipant()
        self.room = nil
        self.showRoomUI(inRoom: false)
        self.callKitCompletionHandler = nil
    }
    
    func room(_ room: TVIRoom, didFailToConnectWithError error: Error) {

    let callKitProvider: CXProvider
    let callKitCallController: CXCallController
    var callKitCompletionHandler: ((Bool)->Swift.Void?)? = nil
    var userInitiatedDisconnect: Bool = false

    // MARK: UI Element Outlets and handles
    @IBOutlet weak var connectButton: UIButton!
