Using both Delay and Auto Turn off in a Routine

Glad you found a solution for this use case. You might also find the following thread of interest:

Replace Groovy with Automations—what’s your plan?