Fixed bug with init not closing device on error