What happens, if you switch off the power ?
Maybe the code just think, the switch is pressed and try to write to the eeprom - while power is falling...