fix problems with exit