Arduino Due gets crazy if unplugged while sending

I tried your sketch with some minor modifications and it works if the board is always powered thru the jack with a 9V battery pack. Although when I plug again the native USB port, I have to plug/unplug/plug until I see the correct Com Port in Tools>Port : (COM8(Arduino DUE(Native USB Port)))

void setup()
{
  SerialUSB.begin(115200);
  while(!SerialUSB);
     
}

void loop()
{
  static uint32_t tm = millis(), ct;
  
  if(millis()-tm>10)
  {
    tm=millis();
    SerialUSB.print("Value :"); 
    SerialUSB.print(ct);
    SerialUSB.println(" ");
    ct++;
  }
}

How do you power the board while native USB port is unpluged ?