Hornby has agreed the sale of a loss-making business as part of strategic efforts to return the model train maker to profitability.