fix a few issues where Close() was called when it could not be. log instead of panic. return error.