In this paper, we develop a stochastic model for an imperfect production-inventory system that faces random quality disruption and has limited time for production. In each time planning horizon, the inventory level is affected by product quality disruption. When the production system switches to the 'out-of-control' state from the 'in-control' state, it starts producing some defective products along with defect-free products, and this switching time is stochastic. The process of the inventory levels at the start of the time horizon is expressed by using a finite and continuous state continuous-time Markov process. We construct mathematical expressions of the transition probability, the steady-state probability, and the long-run average cost. Through a numerical experiment, the near-optimal solution is achieved. The outcome shows that under the situation of production time constraint, the integration of safety stock in an interruption prone production-inventory system, assists in improving the average cost function. The results also show that the optimal safety stock is large when the defect percentage, or the production switching rate, or the shortage cost is very high. Conversely, the small safety stock is desirable when the inventory holding cost or the rework cost is high.