It's important here to understand how the send/pull logic between a fixed resource and a rack works.
By default, a storage object (rack or floor storage) will have its "Pull" option on the Input tab in the properties activated. This means that when an fixed resource sends an item to the port that leads to the rack, this item is 'made available' for the rack to pull. Whether or not the item is actually pulled and moved to the rack is determined by the rack's "Pull Requirement". By default, this tries to assign to a slot to the item based on the rack's Slot Assignment Strategy. Only if this was successful is the item moved.
This means that the item will only exit the queue, firing the On Exit trigger after it has already been assigned a slot. This slot is then overwritten in the On Exit trigger. For the first 5 items this still works, because the code in the On Exit trigger can always find another valid in the rack. However for the 6th item, since it has already been assigned to a slot, there are no empty slots left and "findSlot" returns NULL. This is then set as the item's slot, essentiall removing the slot assignment. The transport still happens though because the item as pulled by the rack before all of this happened. So when the item is supposed to be unloaded to the rack, FlexSim notices that it has no slot assigned to it and uses the rack's Slot Assignment Strategy to find a slot for the item. Since this only checks if there is space, not if there are any items already in the slot, the first available slot is chosen and the item is placed into an already occupied slot.
Fixing this would be easiest by removing the exit trigger and altering the Slot Assignment Strategy of the rack to choose a random empty slot in the first place.
To stop the queue from pulling items while the ASRS is still filling up the rack, you could alter the Pull Strategy to not add a backorder when not item is found. (So the queue doesn't 'wait' for items to be available if it couldn't find one). Then, in the "On Resource Available" trigger of the ASRS, make the queue reevaluate the pull strategy by sending a message to the queue (see On Message trigger of queue) if the ASRS has no further tasks (and thus, no more input into the rack is pending).
Overall, you'd probably have more control by building the pull logic in Process Flow though.
pull-items-fm.fsm