After further analysis of the log files, it looks like this is caused by a server bug - closing the channel seems to confuse the server to sending wrong data which can’t be correctly decrypted and parsed by the client.
The error doesn't occur when the whole session is closed without closing its channels first (which is what many third-party clients such as PuTTY do), and it also doesn't occur when the client ends the shell channel by sending the "exit" command (in that case, it’s actually the server, not the client, that closes the channel).
This means that sending the "exit" command and waiting for the server to close the channel works around the issue:
var scripting = ssh.StartScripting();
scripting.DetectPrompt();
scripting.SendCommand("echo Hello");
string response = scripting.ReadUntilPrompt();
scripting.SendCommand("exit");
scripting.ReadUntil(ScriptEvent.Closed);
scripting.Close();
Closing the whole SSH session might do the trick as well:
var scripting = ssh.StartScripting();
scripting.DetectPrompt();
scripting.SendCommand("echo Hello");
string response = scripting.ReadUntilPrompt();
scripting.SendCommand("exit");
scripting.ReadUntil(ScriptEvent.Closed);
ssh.Disconnect();