Fix for #3 and #23 the blocking CloseDevice()
Merge pull request #29 from rvlieshout/master

Tried to address the issue that blocks the CloseDevice call.