Improve error messages for unterminated strings

Includes test for #3379 as requested in #3380.