In this work, the influence of cell shape sampling on the predicted stability of the different metastable phases in flexible metal–organic frameworks at finite temperatures is investigated. The influence on the free energy by neglecting cell shape sampling is quantified for the prototypical MIL-53(Al) and the topical DUT-49(Cu). This goal is achieved by constructing free energy profiles in ensembles either in which the phase space associated with the cell shape is sampled explicitly or in which the cell shape is kept fixed. When neglecting cell shape sampling, thermodynamic integration of the hydrostatic pressure yields unreliable free energy profiles that depend on the choice of the fixed cell shape. In this work, we extend the thermodynamic integration procedure via the introduction of a generalized pressure, derived from the Lagrangian strain tensor and the second Piola–Kirchhoff tensor. Using this generalized procedure, the dependence on the unit cell shape can be eliminated, and the inaccuracy in free energy stemming from the lack of cell shape sampling can be uniquely quantified. Finally, it is shown that the inaccuracy in free energy when fixing the cell shape at room temperature stems mainly from entropic contributions for both MIL-53(Al) and DUT-49(Cu).