I don't know why it stops after three hours.

Is it wise to do that from an interrupt context? I think I would just watch millis and call the function every five seconds before I added extra complexity of a library and an interrupt.