SSH2: update conditions under which _disconnect's code is executed

Fixes #582