Have you tried a short press on the real power button to see if that works? You need to get the Pi out of the loop at this stage and make sure that is being captured, and if not then look into why. If that seems to be captured but the system does not shutdown tidily then it is probably worth raising it as a bug report.