Refactor D-Bus implementation

Improved the exit handler to ensure the main thread successfully
completes by joining on the main thread.