Explicitly clean up BTS singleton

Add method to explicitly cleanup BTS singleton similar to GprsMsStorage
class and use it from main(). The destructor becomes trivial wrapper
around cleanup() method.

This prevents annoying SIGABRT on exit of OsmoPCU caused by
rate_ctr_group_free() being called after talloc_free() which removes the
context in which counter group is allocated.

Change-Id: I796d56a7de3f3a1f9d59708995c8e3e9b05a2747
diff --git a/src/bts.cpp b/src/bts.cpp
index 1804c52..e07b840 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -197,6 +197,11 @@
 	return BTS::main_bts()->bts_data();
 }
 
+void bts_cleanup()
+{
+	return BTS::main_bts()->cleanup();
+}
+
 struct rate_ctr_group *bts_main_data_stats()
 {
 	return BTS::main_bts()->rate_counters();
@@ -239,16 +244,27 @@
 	OSMO_ASSERT(m_statg);
 }
 
-BTS::~BTS()
+void BTS::cleanup()
 {
 	/* this can cause counter updates and must not be left to the
 	 * m_ms_store's destructor */
 	m_ms_store.cleanup();
 
-	rate_ctr_group_free(m_ratectrs);
-	osmo_stat_item_group_free(m_statg);
+	if (m_ratectrs) {
+		rate_ctr_group_free(m_ratectrs);
+		m_ratectrs = NULL;
+	}
+
+	if (m_statg) {
+		osmo_stat_item_group_free(m_statg);
+		m_statg = NULL;
+	}
 }
 
+BTS::~BTS()
+{
+	cleanup();
+}
 
 void BTS::set_current_frame_number(int fn)
 {