public final int closeAndGetEncodedLength() {
        flushBuffer();
        if (bits > 0) {
            ab[++idx] = (byte) (b & 0xff);
        }
        return idx + 1;
    }
flushes and closes the (write-mode) context

@return the encoded length in bytes
main/src/main/java/cgeo/geocaching/brouter/util/BitCoderContext.java