To lose XP boost is similar to lose Stamina, you will just lose it while gaining experience points. In case you are bleeding, or have on you any kind of curse you will NOT lose XP boost.
About the case you mentioned, you'll lose XP boost only if another player pass passes through the place and kill some creature that you've already hited, so hit, So you will gain some experience points and your Xp boost and Stamine XP boost and Stamina will decrease.