Create a common function for Hive objects closing