Fixed exit functionality