Fixed a nullpointer when app terminates. This made the app unusable for 5 seconds