Factored device title printing code out into pv::DeviceManager::format_device_title

This fixes the earlier bug where pv::DeviceManager::compare_devices
would crash if any of the device string fields were NULL.
Added assertions to confirm that the session was terminated cleanly
Set the title of the main toolbar