added the exit functionality