Improved onPause.