fixed exit functionality