Avoiding a NPE when stop an app