fixed a bug with memory leak whed closing the app by the cross button