For the law of conservation of momentum to hold, the system must be closed (no mass enters or leaves) and isolated (no external forces acting on it).