Shortcuts will usually stop your program after four or five minutes, but this will stop that. Use a number block with the number of seconds you would like to wait, then call this Shortcut from a Run Shortcut block. Tested up to 10 minutes in the background, but can theoretically run indefinitely. Also see this shortcut to delay by minutes instead of seconds.