Fix for #3 and #23 the blocking CloseDevice()