Serial.println() crashes Arduino

Here is how to reproduce the problem:

  1. I tried the example in the millis() reference page millis() - Arduino Reference.
  2. Loaded it in Arduino (used Mega 2560). Everything works fine: millis() is printed each second incrementing properly.
  3. Disconnected the "Serial Monitor" (on Mac OS X 10.11.5) by closing the window.
  4. Re-connected "Serial Monitor" (opened it a gain). When the Arduino connected, Time using millis() started counting from 0, which is an indication that the Arduino got re-set.

Should this be happening?
Is there an undocumented exception that is being thrown that could be captured in a try-catch block?

Please help.

J0RDAN:
4. Re-connected "Serial Monitor" (opened it a gain). When the Arduino connected, Time using millis() started counting from 0, which is an indication that the Arduino got re-set.

Should this be happening?

Yes. That is the auto-reset circuit that allows for easy uploads. You can disable it by connecting a 1-to-10 microfarad capacitor between the Reset pin (+) and the Ground pin(-).

J0RDAN:
Is there an undocumented exception that is being thrown that could be captured in a try-catch block?

No. The serial hardware is pulling the Reset pin briefly low to cause a hardware reset.