Maybe he didn't just die from the juubi being extracted. The fact that he was pretty much caught off guard only to be pierced in the back by black zetsu only to explode and change gender completely before transforming into a chakra 'goddess' would have been more than enough to kill him. Plus he probably feels he has no reason to live anyway since his dream was pretty much crushed soo... It's not really a plot hole.