when a remote close is received and output buffers aren't empty yet, the local channel is left in open state and delayed//close is set.
when the buffers are later emptied, the local channel state is however not closed.
using the channel close callback helps in detecting this condition, but it shouldn't be needed and (unless the channel is also explicitly requested to be closed locally upon this detection) doesn't solve the fact that the local state remains wrong.
i found this reported in this thread already: http://www.libssh.org/archive/libssh/2011-06/0000029.html
but not as a bug.
the source mentions some TODO to fix the delayed close, perhaps this issue is what that refers to.