Lay the stair rail on the stairs. Place a mark on the railing where the wall molding's mitered joints touch the railing. If your stairs do not have molding, use the bottom and top stairs' noses -- the front lip portion.
Lay the stair rail on a miter saw, right-side up. Position the miter saw to a 45-degree right-hand cut to cut along the mark on the rail's top end. Change the saw blade to a 45-degree left-hand cut to cut along the mark on the rail's bottom end.
Install the railing's mounting brackets on the wall, according to the manufacturer's directions. Set the railing on the brackets and measure the distance from the railing to the wall. Transfer this measurement to the two small mitered ends.
Set the miter saw to a 0-degree straight cut and cut through each piece to make them the appropriate length.
Spread a thin layer of wood glue over the little pieces' mitered ends. Push the little pieces onto the railing's mitered ends to form a 90-degree angle toward the wall. Drive finishing nails through the two pieces, with a pneumatic nailer, to hold them together. Mount the railing on the brackets.