I don't know why you're getting a duplicate disconnect. I wasn't able to reproduce your issue in our environments specifically because we already had the proposed patch applied in our local stable tree.
The patch (from Dan Smith) is a backport from what went into master some time back, which accepts 0 and 255 as exit codes for disconnect operations. It will mitigate this problem.
I don't know why you're getting a duplicate disconnect. I wasn't able to reproduce your issue in our environments specifically because we already had the proposed patch applied in our local stable tree.
The patch (from Dan Smith) is a backport from what went into master some time back, which accepts 0 and 255 as exit codes for disconnect operations. It will mitigate this problem.