Bugfixes of --pre-exit-hook