On either a treadmill or stair machine or stairs I recommend no holding on to the railings to help train balance. All three of these already have uniform surfaces so offer very little in the way of a balance challenge. Holding the rails removes even that small effect and takes some of the load off your legs. You will benefit more from a stair machine than a treadmill unless your treadmill will go very steep (30+%).
Scott