Command Line Baking

My current project involves lightmapping procedural geometry. I have an editor menu item that builds the geometry, assigns lightmap UVs, and bakes the lightmaps. This all works fine if I keep the editor open the whole time (see image 2), but I need to be able to do this via command line and exit on completion. When I execute the method via command line and close the editor immediately after the bake, the lightmap index is 65535 (unassigned) and my mesh appears black (image 1). Compare to the default Unity cube in both images, which gets lightmapped correctly each time.
If I leave the editor open for a second or two after the bake completes, then it looks fine. But if I close it immediately (as happens when using the -quit command line parameter), my mesh appears black. It’s as if there’s a lightmap job in the background that is still working even though Lightmapping.isRunning is false, and so far the only way I’ve managed to get correct lightmaps is to simply wait a bit after the bake. I’ve tried to artificially delay closing the editor using Lightmapping.complete callbacks, EditorApplication.update callbacks, C# Timers since I don’t have coroutines in the editor, and nothing works.

I’ve solved it. I was using Unity 5.3.3, and it was as simple as updating to Unity 5.3.5f1.