close gracefully