Fix bug: escape escaped double quotes properly

The previous code used to ignore all closing quotes if the same token
also has an escaped double quote. For example, in

-Dkey="I am the \"man\""

the last token contains both escaped quotes and valid quotes. This
used to be interpreted as a token that doesn't have a closing quote
when it actually does. This is fixed in this commit.