Fixed bug with exit