Properly close shelf upon restart

This fixes some data loss (plugins, repos, etc.), as shelves
are only written back to file if they're explicitly closed.