The opening and closing of the serial port on the PC causes the Arduino to reset because of the auto-reset feature on the Arduino board. This is so the Arduino IDE can force a reset to enable uploading of new sketchs to the board.
That might need to be qualified to when using the arduino USB serial interface. It may not apply when using other methods of connecting a pc serial port to the arduino.