for adding exit functionality