move pre_shutdown() call in the context of the child process instead of the main-process (thanks defransen)