I searched for a solution, I looked at the documentation, I read several blog posts and I found out that at this time what you are asking is impossible.
Moreover someone asked a similar question on GitHub, Support for html fragments, but it was closed with the answer:
Hm, I don't think there's much we can do about this, since minifier really needs to be context aware and can't understand what to do with arbitrary, partial chunk of html.
So this is not possible and this is (probably) not going to be implemented in the future.
You can't block that process (with grunt-contrib-htmlmin) because their intent is to specifically prevent users from leaving "uncorrect code".
I did not find any other equivalent grunt-plugin that gives you that possibility.
In the end I think you have only two "solutions" left:
1)Not minifying your php fragments;
2)Divide your code into more parts, minify only the one without unclosed tags, and reunite them all using grunt-include-replace, or a similar plugin, in a new php file.