Improved exiting. Now application stops all backends threads before exiting.