Fix ending with an empty chunk per comments in #2764.