In this paper, we provide a closed-form solution to an optimal portfolio execution problem with stochastic price impact and stochastic net demand pressure. Specifically, each trade of an investor has temporary and permanent price impacts, both of which are driven by a continuous-time Markov chain; whereas the net demand pressure from other inventors is modelled by an Ornstein���Uhlenbeck process. The investor optimally liquidates his portfolio to maximize his expected revenue netting his cumulative inventory cost over a finite time. Such a problem is first reformulated as an optimal stochastic control problem for a Markov jump linear system. Then, we derive the value function and the optimal feedback execution strategy in terms of the solutions to coupled differential Riccati equations. Under some mild conditions, we prove that the coupled system is well-posed, and establish a verification theorem. Financially, our closed-form solution shows that the investor optimally liquidates his portfolio towards a dynamic benchmark. Moreover, the investor trades aggressively (conservatively) in the state of low (high) price impact.