Application lifecycle handling