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.
You have two choice to work around this 'feature'
-
Defeat the auto-reset feature with either hardware changes to the board or depending on what PC OS you use defeat the DTR signal in the PC serial software handler. If you search this forum for auto-reset you should find plenty of confusing ways to accomplish this.

-
The AVR processor chip has built in EEPROM memory where you can write and later read back data values stored in it. http://www.arduino.cc/en/Reference/EEPROM
Not hard to read the saved count value after a reset or power up cycle to restore the variable. The trick part is how to detect an upcoming reset or power down condition so that you can write the current count value into the EEPROM before the chip powers down or resets ??
Lefty