App Terminate by OS when put in background

Hi Team I am facing a problem when I put my app in background and after a while due to CPU over usage it gets terminated. Now I am managing a web page session in another tab which is quite important for us and we want that if app got terminated by OS then we redirect user to the previous activity he is having but for that I need to render a flag, but here I am facing problem because applicationWillTerminate function is not letting me change any value in NSUserDefaults and I am stuck at this point. So if anyone has any idea how can we achieve it, it would be a good help for us.

Thanks & Regards Mayank Sharma