Sounds like the switch on the kickout hole to the toybox needs to be adjusted. If you lift the playfield, you will see a switch with an arm in in the kickout. Slightly loosen the switch mounting screws and pivot the switch to push the arm higher into the kickout hole. This should allow the switch to register. Don't move it too far or the ball may not be able to roll over it and trigger it.
Your loop switch not registering is probably a switch that needs adjusting too.
When your toybox dumps the balls, is that also when the ball is softly ejected from the toybox kickout hole? If so, it sounds like your game is going into ball search. Because your toybox kickout switch is maladjusted, the game does not know it is in the kickout and starts firing solenoids and cycles the toybox to try and dislodge the ball. Fixing the kickout switch should avoid this in the future.