The decision brings to a close a years-long court battle that irked Musk so much he moved Tesla's incorporation from Delaware to Texas.