This paper seeks to make joint decisions on preventive maintenance level and production quantity for manufacturing systems subject to stochastic demand in a finite-horizon. Standard models for scheduling preventive maintenance typically ignore the throughput target variation due to demand uncertainty and specify instead a constant demand rate. We show that maintenance decisions should be integrated with production decisions to accommodate the demand uncertainty. To achieve this objective, preventive maintenance (PM) flexibility is introduced as the opportunity to select and implement maintenance tasks at different levels, which can be viewed as real options to the manufacturer. PM levels can be defined according to the degree to which the machine condition is stored by maintenance. A preventive maintenance can be a minimal, imperfect, or perfect one. By leveraging PM flexibility, this paper proposes a model to determine optimal production quantity and PM level for a single-product manufacturing system with a finite planning horizon. A real option analysis (ROA) is developed to quantify the benefits and costs of PM flexibility. We derive optimal joint decisions for maintenance and production that maximize the overall expected profit of the system. We compare the proposed PM-flexible model with the conventional PM-fixed model in a case study. The results demonstrate the condition that the PM-flexible model outperforms the PM-fixed model in terms of option value (expected operating profits). We also show how the growth in demand volatility affects the optimal decisions and overall profitability. These results have important implications for making maintenance and production decisions, especially in industries that feature high demand volatility.