Assert that the last character is semicolon before reducing length to strip it.

Based on concern of Noah Misch.