Either there is some code missing above, or you’ve only posted part.
It looks like you didn’t count within your loop. Try using:
$count = $books->post_count;
within your loop and then at the bottom just use:
if($count > 6) {
but that all needs to be within your loop (before the endwhile.) I don’t see anywhere where you reset your postdata here either, so it still MAY work, but I’d suggest changing the code a bit if this is it in entirety.