You could try capturing the time when you turn it on, then when you see the time elapsed that you want you turn it off.