Reset coded stream if it is close to the limit, flush on close