Is it safe to use setInterval for long time

my client has request to open pop up pin if the users idle for 30 mins.
i have create the concept and lets see in the big picture

  1. if users input pin success, then i will start the threadPIN interval for every 1s to check if current timestamp is bigger than lastActivityTimestamp + 30mins. this will continue untill condition true.
  2. while condition number 1 is false, variable lastActivityTimestamp will update every change the pages
  3. if condition true, then i will stop threadPIN and ask to input pin again. then back to step 1.

is it safe to use the concept if the timeout is set for a long time, lets say 30 minutes. i wonder if it will stop if the client make apps in the background, is the interval still continue? or blocked by the operating system? thanks