Fixed error on application shutdown