Adding a close function