How to set delay in the routine?

Hello! I would like to set a delay in my routine. Here is how it works:
in one routine, the end condition is met. And I want to let the interface stay for 5 seconds. How to build this delay?
I tried the method in the previous questions like:

            endTime = core.Clock()

if game_over and core.Clock()> endTime+10.0:
    continueRoutine = False

But it can’t work well. Did I do anything wrong?

Begin Routine

endTime = 0

Each Frame

if endConditionIsMet:
     if endTime == 0:
          endTime = t + 5
     elif t > endTime:
          continueRoutine = False