[TL:DR] - If you can comfortably hold the nozzle with your fingers, you are good to go
In order to understand how long one should wait, it is important to understand why one has to wait.
All modern consumer-grade FDM printers have their printing head made of two assemblies: the cold end, where the extruder stepper motor is located and the filament must be in solid state, and the hot end, where the filament is actually melted and pushed through the nozzle.
Between the two there is a thin-walled length of pipe called heat break, whose purpose is to keep the two separate and make difficult for heat to reach the cold end by conduction.
However, the heat break is not "watertight", and heat also transmits via the convecting motion of air and IR radiation, so the cold end is actively cooled (most commonly with a fan).
The reason you want to wait before switching off the printer is that you want to keep that fan spinning until there is no chance for the heat to creep up and melt the filament in the cold end.
If the filament were to melt in the cold end, the extruder would clog and you would probably need to disassemble it.
In order to make sure the cooling happens, you have to make sure that your G-code tells the printer to stop heating the nozzle, after the print is done.
All slicers that I know of have a specific configuration setting called "end G-code" or something similar where you can manually insert the code you want to execute at the end of each print. The part relevant to your question could look like this:
M104 S0 ; turn off heating block
If you want to get fancy and your hardware has a beeper you may also try:
M109 S60 ; wait for nozzle temp to drop to 60 °C
M300 S300 P1000 ; make a beep sound
Typically "end G-code" has other stuff too (move the head out of the way, switch off the heated bed, disable the idle hold of the steppers...)
Just make sure to move the nozzle away from the printer as your first action: you don't want the hot nozzle to linger idle above the print and ruin its top layer!