Explicit close() function to close and unset the handles