Properly account for ending commas and brackets.

If they weren't accounted for, they could be placed on the next line. We
prefer to have ending delimiters on the same line as the last element of
the container.