I made the changes in the program, but the segments still stay lit, the hardware is simple 16f819, 2 relays, 2 transistors, TM1637, 1 switch to press and allow you to see the count in tmro, but I think that if the segments stay lit the batteries will run out.
Do you think that the problem of the segments turning off can be corrected or there is a solution for very low consumption
How have you wired the switch as you have not mentioned if using a pull-up or pull-down resistor.
You can't just connect a SPST switch to a pin and + supply without having an external pull-down resistor
Or SPST to pin and ground without having an external pull-up resistor or a c code block that enables an internal weak pull-up.
I can't tell from your hardware if you have the external resistor, hence reason for asking for a full schematic.
I have tested the TM1637 Quad 7seg LED and the off is working on embedded hardware, which suggests an issue with your flowchart or hardware or both.
What the circuit should do is keep counting no matter what.
The display should only be on With the switch pressed.
If that is the case then great!
If the display is on all the time then best to measure the voltage between pin A0 and GND when the switch is not pressed.