Fixed an segmentation fault in case of exiting XBMC.
Merge pull request #2 from tzickel/master

Fixed bug that could cause connection to close prematurely.