Joe, I guess that I have been lucky always having a door frame or something to "stop" the chair rail but I believe the the following is right. Cut the long piece with a 45 degree miter with the long point equal to the "end" of the wall and install this. Cut a small triangular piece with a 45 degree miter on one end and a 90 degree cut on the other end and a total length of the piece equal to the thickness of the chair rail. This is kind of hard to describe but it is similar to the way you put a return on the end of a stair handrail. or finish the apron under a window. Glue the short piece in. Putting a nail in it will surely split such a small piece. Be careful making the cut on the small piece. Cutting short pieces can get pretty scary.