The battery life indication is just that - an indication based on current/average use. Instagram - among many other media-heavy apps - is notorious for heavy battery use.
When you were using Instagram, the phone thought - based on current use (i.e. heavy because it was acting up and sucking up resources trying to do calculations) - that it would lower down to 27% if it continued at that rate for the near future.
However, when you stopped using Instagram (turned phone off), the memory was freed, the calculations and allocations didn't have to happen anymore and the phone then thought: ok, based on the current light use situation, it looks like it's actually at 42%.
This indication comes from the same principle when introducing the concept of average in Statistics 101: "A man drowned in a pool with an average depth of 1 foot" (the point being it's not the weighted average). The average of 2 2 5 8 1 9 1 is 4, but what if the 1 in the weighted average has a weight of 8? Then the average is 6.6, making it a heavier estimate. Refer to the situation above.
I hope this makes some sense.