Auto power off without delay

Hello,

I want to shut down my arduino after about 1h. I have read a lot of information, so its all clear to me.
But...
I have a program to control a touchscreen and driving 2 stepper motors.
I had a lot of problems with lags in the code, so i think auto power off in the code will bugg it.
Is there a way i can fix it without interrupting or screwing my code?

Or should i use an extra arduino (uno or micro) to do this?

One way is by recognizing that millis() will return the number of milliseconds from power on. Also there are 3,600,000 milliseconds in 1 hour.

So, add something to your loop that checks that the value returned by millis() is greater or equal to 3.6M start the process you have devised to shut down.

The fastest way for us to help, is to post your existing sketch in tags.

To power off your project requires some control of the incoming power source (not on the Arduino), but you may be happy with low-power sleep mode.
Take a look, there are many existing threads.

Edit: ADDED
Ref @sembazurus post, often it is worthwhile to maintain a tick counter - e.g seconds or minutes, rather than raw mS. Then you can deal with events at a more leisurely pace.

Thanks for the reply.
I will take a look, maybe i could use an NE555 timer.
Now i'm verry bussy with other projects, so it will be at the background for a time.