             //we need to put the commissioner into listening mode by sending the command
             self.commissionerDevice!.transceiver!.sendStarListening { result in
                 self.log("commissionerDevice.sendStarListening: \(result.description())")
+                if (self.canceled) {
+                    return
+                }
                 if (result == .NONE) {
                     self.stepComplete()
                 } else {

    private func setSetupNotDone() {
        self.targetDevice.transceiver!.sendDeviceSetupDone(done: false) { result in
            self.log("targetDevice.sendDeviceSetupDone: \(result.description())")
            if (result == .NONE) {
                self.log("Device reset complete")
            } else {


        self.targetDevice.transceiver!.sendCreateNetwork(name: self.newNetworkName!, password: self.newNetworkPassword!) { result, networkInfo in
            self.log("targetDevice.sendCreateNetwork: \(result.description()), networkInfo: \(networkInfo as Optional)")
            if (self.canceled) {
                return
            }
            if (result == .NONE) {
                self.log("Setting current target device as commissioner device")
                self.commissionerDevice = self.targetDevice
