There's a good chance this is intended so that when you are attacked by a mob the inventory closes and you can quickly defend yourself. However if your are on fire it is impossible to open up the inventory to but a bucket onto your hotbar.
Probable my most common cause of death in the game. If this does work as intended perhaps the game can differentiate between mob and environmental damage.
Does this bug still appear in 0.13.1? If so please respond.