Motivated by this very general research question, we develop a novel scheduling framework, in which we integrate the modeling and scheduling of flexible manufacturing systems. It allows exploiting the flexibility of manufacturing systems for the production of customer specific goods in the scope of Industry 4.0. The basis of the proposed framework is a modular description of the manufacturing system in the form of a flexible job shop. Automatic model generation algorithms lead to a Petri net model of the system, which enables systems theoretic analysis and the application of model predictive control (MPC), a modern feedback control method. In the MPC formulation of the scheduling problem, the economic goal of the manufacturing system is pursued. By considering feedback from the system, the MPC is able to react to unexpected changes in the manufacturing system and to make optimal use of the flexibility to adjust the production process. The advantages of the framework are its applicability to a wide range of scheduling problems, its ability to model and to exploit the available flexibility for economically optimal operation, and its guarantee to solve the production problem in closed loop operation.