Design of handler for System.on() using firmware_update_pending

Just seen this thread post System Events param problem from February - I was wondering why the event and param printout was the wrong value 129 and 512 whereas I was expecting 512 and 0. Now I have fixed that I am trying to understand why the flash sometimes happens and sometimes does not.

The handler is now:

void handle_restart_events(system_event_t event, int param)
{
    #if DEBUG
    Serial.printlnf("got event %lu with value %d", (uint32_t)event, param);
    #endif
    if (event == firmware_update_pending)
    {
        #if DEBUG
        Serial.printlnf("stop SD file read/write activity runState %i", runState);
        #endif
        isFirmwareUpdatePending = true;
        unsigned long sdTimeout = millis();
        while (isSDbeingAccessed && (millis() - sdTimeout < 500))
        #if DEBUG
        Serial.println("Finished waiting for SD card activity to stop");
        #endif
        prevRunState = runState;
        runState = D_GOTOWAIT_FOR_FLASH;
        System.enableUpdates();
        #if DEBUG
        Serial.println("Re enabled flashing");
        #endif
    }
}

My debug output is as follows:

got event 512 with value 0
stop SD file read/write activity runState 1
Re enabled flashing
Prepare Wait for flash to happen in goToWaitForFlashController() prevRunState 1
Waiting for flash to happen in waitForFlashController() for 0.0 secs
Waiting for flash to happen in waitForFlashController() for 1.0 secs
Waiting for flash to happen in waitForFlashController() for 2.0 secs
Waiting for flash to happen in waitForFlashController() for 3.0 secs
Waiting for flash to happen in waitForFlashController() for 4.1 secs
Waiting for flash to happen in waitForFlashController() for 5.1 secs
Waiting for flash to happen in waitForFlashController() for 6.1 secs
Waiting for flash to happen in waitForFlashController() for 7.1 secs
Waiting for flash to happen in waitForFlashController() for 8.1 secs
Waiting for flash to happen in waitForFlashController() for 9.1 secs
Waiting for flash to happen in waitForFlashController() for 10.2 secs
Waiting for flash to happen in waitForFlashController() for 11.2 secs
Waiting for flash to happen in waitForFlashController() for 12.2 secs
Waiting for flash to happen in waitForFlashController() for 13.2 secs
Waiting for flash to happen in waitForFlashController() for 14.2 secs
Waiting for flash to happen in waitForFlashController() for 15.3 secs
Waiting for flash to happen in waitForFlashController() for 16.3 secs
Waiting for flash to happen in waitForFlashController() for 17.3 secs
Waiting for flash to happen in waitForFlashController() for 18.3 secs
Waiting for flash to happen in waitForFlashController() for 19.3 secs
Waiting for flash to happen in waitForFlashController() for 20.4 secs
Waiting for flash to happen in waitForFlashController() for 21.4 secs
Waiting for flash to happen in waitForFlashController() for 22.4 secs
Waiting for flash to happen in waitForFlashController() for 23.4 secs
Waiting for flash to happen in waitForFlashController() for 24.4 secs

whilst waiting the LED is breathing cyan - sometimes the flash is successful but most times it just times out.

Whilst I am waiting for the flash to happen I am in a finite state in the main loop. I am calling Particle.process() and then delaying for a second.

    Serial.printlnf("Waiting for flash to happen in waitForFlashController() for %3.1f secs", (float)(millis()-waitms)/1000);
    Particle.process();
    delay(1000);

What is causing this apparent blocking of the flash after it has been System.enableUpdate();?