Merge "Fix dangling pointer bug when transitioning to background."