Handle unacked bytes when closing a stream

Whn we close a streamt here may be some items that we weren't able
to process. We need to make sure that these items are accounted for
in free bytes so that flow control doesn't get out of sync.

Change-Id: I7b220cc574599c856aa040030c77ef442a4c922a
Reviewed-on: http://review.couchbase.org/37920
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>