Merge "Close native handle properly." into tm-dev