When you are close to finishing a mission, make sure before the last hit that you don't have too much energy left as this will be lost when as part of finishing your mission it gives you five upgrade points and refills your energy to max.
It happened to me with40 energy points I could have used before getting 51 more when it maxed out.