Add a monkey patch to fix the session termination issue.

@fnichol should I submit this upstream? Pretty sure it should be safe in general.
Remove refactored SFTP code.
Clean up the shutdown code.