Implement some cleanup process
Currently in lua we have some sort of exceptions implementation but we have nothing hooked up to it do do real cleanup in most of the cases. And in C we in most cases just call die, specially in cases when we receive error from Lua. This is just bad, with any error small or big we do no cleanups and if we expect some sort of cleanup (like I don't know running postupdate hooks or closing status files and more) it is not executed and in most unexpected ways skipped.
So solution should be some global cleanup stack in utilities. Idea probably should be something where you can register (and unregister) functions that would be called when updater is going to exit. This should simplify for example main functions a lot (because right now it's just a pile of error handling shit) and should ensure that even if we trigger exit from some function that is no way relevant but should result to propper exit that we do propper cleanup and then exit.