fixing freeze on stopping application