CMMotionManager stops sending gyro updates without calling stopGyroUpdates

I'm trying to create a productivity app that utilizes gyroscope data to detect when the phone is picked up. However, in my code, it seems that after I detect the phone flipping over, gyro updates become unavailable and I start receiving the sentinel value instead, which causes the code to not work properly. What happens is that I will receive gyro updates until faceUp changes value, at which point gyroData becomes unavailable.

                    let dTheta = Double(self.manager.gyroData?.rotationRate.y ?? 0)
                    
                    if dTheta > 0.1 || dTheta < -0.1 {
                        totalRotation = totalRotation + dTheta
                    }
                    tO = Date.now
                    
                    if(totalRotation >= 0.9 || totalRotation <= -0.9) {
                        //Block that detects a phone flip
                        if faceUp == true {
                           
                            faceUp = false
                        }
                        else if faceUp == false {
                            
                            faceUp = true
                            stopText = "Timer paused at \(currentTimeRemaining)"
                        }
                        totalRotation = 0
                    }
                    
                   guard shouldProceed() else {
                       
                        return
                    }
                    
                    currentTimeRemaining = dispTime(mustRedo: mustRedo)
                    keepScreenOn()
                    let hours = job.hours
                    let mins = job.mins
                    let secs = job.seconds
                    
                    if mins == 0 && hours == 0 {
                        minsDone = true
                    }
                    if secs == 0 && mins == 0 {
                        secsDone = true
                    }
                    if mins == 0 && minsDone == false {
                        job.setHours(new: (hours-1))
                        job.setMins(new: 59)
                    }
                    if job.seconds == 0 && secsDone == false{
                        job.setMins(new: (mins-1))
                        job.setSeconds(new: 59)
                    }
                    if hours == 0 && minsDone == true && secsDone == true {
                        workTimeActive = false
                        //stopTimer()
                    }
                    else {
                        job.setSeconds(new: job.seconds-1)
                    }
                    if manager.isGyroActive == false {print("not active tag 3")}
                    currentTimeRemaining = dispTime(mustRedo: mustRedo)
private func keepScreenOn() {
        UIApplication.shared.isIdleTimerDisabled = true
    }
private func shouldProceed() -> Bool{
        if faceUp == true {
            if manager.isGyroActive == false {print("not active tag 4")}
            return false
        }
        return true
    }
CMMotionManager stops sending gyro updates without calling stopGyroUpdates
 
 
Q