Fix heredoc matching for trailing quote

The file lib/nova_plugins/hypervisor-libvirt does heredoc's like this:

---
bash -c "cat <<EOF > foo
...
EOF"
---

The trailing quote was throwing the matching in bash8 off and it kept
appending the next file as if it was still part of the heredoc.

This fixes the match to recognize this, and additonally adds a check
that raises an error if we finish a file and we still seem to be in a
heredoc

Change-Id: I5e547d87b3921fc7ce6588c28f074e5c9f489c1f