We consider the problem of optimal position liquidation where the expected cash flow stream due to transactions is maximized in the presence of temporary or permanent market impact. A stochastic programming approach is used to construct trading strategies that differentiate decisions with respect to the observed market conditions, and can accommodate various types of trading constraints. As a scenario model, we use a collection of sample paths representing possible future realizations of state variable processes (price, trading volume etc.), and employ a heuristical technique of sample-path grouping, which can be viewed as a generalization of the standard nonanticipativity constraints.