Measure how far the chair rail will stick out from the wall, using a tape measure. Do the same for the trim around doors or windows that it will butt against. Where the chair rail will end against trim that sticks out farther than it does, cut the chair rail off square on the end with a handsaw or table saw and position it against the trim. Sand it if necessary and attach it with finishing nails as you normally would.
Saw the chair rail just long enough to fit up against door or window trim that's not as thick as it is. Hold the chair rail in place and trace a pencil line vertically across the end, using the door or window trim as a guide, so you have a mark showing how far the chair rail sticks out beyond the trim.
Saw the chair rail at a 45-degree angle so it bevels back from the trim, starting at the pencil line, using a handsaw and a miter box or a table saw set at a 45-degree angle. Sand the saw cut to remove any rough edges, if necessary, and attach the chair rail with finishing nails.