Use reference counting to dispose the application when needed