Refactor 'pkg [-v|-vv|-vvv]' handling

  * Break the large chunks of code to handle dumping config into
    their own files

  * Add whitespace and make everything line up prettily so the
    output is actually readable.

  * Use atexit() to register cleanup functions

  * Change signature of pkg_shutdown() and pkg_plugins_shutdown()
    to void fund(void) appropriately for use with atexit()

  * Consequently use _exit() from within cleanup functions
Update tests to account for modified pkg -vv output.