Hi Guys.
I had the same problem with my battery, showing 40% and shutting down. I did everything as suggested so, in the end I contacted Apple support as my MacBook Pro still had Apple cover. They did everything over the phone but could not solve the problem. So, they arrange an appointment at one of their stores. One of the Tech guys there did a system check and came back five minutes later and said it’s the battery even though all the checks showed the battery was ok. He showed me a graph on his test system, if your battery is ok it shows a white dot in a green box and it should move from top left to bottom right. But the white dot in my test , was showing it was moving vertically down in the green box. He said it shows the battery will fail, and that’s why you are getting the problems. If the dot is in the green box the system will always say the battery is ok but it’s not. They changed the battery and have had no problems since.
Michael