Fix possible peer deadlock when peer completes.
Changelog.
Merge fix for deadlock.