That's a problem that can happen when you use the "kill for" command to farm an item until its max stack, if grimoire doesn't pick up an item it will normally get it when another one drops, but if it is the last one before the max stack then another one won't drop making it get stuck.
The only way I know to avoid that problem, is to just loop a normal kill command with a get drop command.
So pretty much:
[Start]
Kill *
item has dropped: drop
Get drop: drop
is not in inventory : drop amount
goto label: Start