Yes it is legal. You can sell the car in any state. The taxes will be paid in the state that the buyer registers the car in.