There are a couple things to consider as to determine if the course of fire is over.
One is whether the gun was holstered.
In my case I had finished a stage (of course, the last stage of the match) unloaded, showed clear, place the gun in the holster, and when I went to apply the lock the pistol fell to the ground. Somewhere during the stage I must has rubbed the lever for the lock so when I placed the gun in the holster it did not go in all the way and fell out when I took my hand off the gun. Since it was not in the holster properly the gun was not ‘holstered’ and therefore the DQ applied.
Secondly, which rule book is being used for the match.
IPSC rule is the 8.3.7.3 – COF ends when hand is off holstered gun after the “If Clear, Hammer Down and Holster” command.
USPSA rule is 8.3.8 – COF of fire ends after the “Range is Clear” command.
Personally I prefer the IPSC rule as it is more consistent. I’ve been at matches where the RO calls out the shooter’s time first, then ‘Range is Clear’, or gets distracted and then a while later says “Oh yah, Range is Clear”.