Can we see some code for this please.

Also not sure if it applies but as I recall the startup script has a 10 minute completion period, meaning that if what you're trying to do is not done then it will quit on it's own. I'd have to locate that exact setting but I think it was even posted here a while ago.