You can make the walls thicker and/or reduce the speed of the ball.
Motion is an illusion, objects move by teleporting a bit each frame which can cause collisions to be missed. What’s probably happening in your case is the collision response is struggling with that particular collision polygon so it’s perhaps pushing out in the wrong way.
Anyways another idea could be to clamp the balls position inside the box. Something like
Set x to clamp(self.x, box.bboxLeft+radius, box.bboxRight-radius)
And do the same with y with top and bottom.