Added a close function