But the problem with the code in the given link is that its destructor is never called. So if you do some important stuff in the destructor then it will never get executed. So another method to do this is, return a reference of a static object from the getInstance() method without any check for initialization. Since its a static object it will exist in the memory till the end of the program and once the program exits, this static object will be destroyed.
The principle behind this method is function static objects are constructed only once. So next time when you call getInstance() reference to the already constructed instance is returned.