thanks for the answer.
Is there a way to solve the issue?
I do not understand how to use frictionless contact since the body that should separate out should always be constrained to avoid rigid body motion.
However, given that how can I constraint the body that separates out? Could a spring connecting that body to the ground suffice? Or should it be connected to the above box? A spring could prevent translation in 2 directions and three rotations I think.