In the presented work, we attempted to carry out a quantitative evaluation of a closed agricultural system, with the aim of increasing its stability and invariance. Closing the agricultural system in the first degree means using a part of waste materials in a submontane and mountain farm for the production of biogas. The second degree presupposes the inclusion of crops rich in energy– oil-seed rape - into the inner structure of the system, and finally the third degree of closing the system considers using biogas for transformation of a part of starch production – cereals – into ethanol as a fuel. The principle of closing the system requires the optimization of its inner structure relying on the principle of well-balanced state of the carbon processes