Light fixture goes out just before flush to ceiling
For folks reading this in the future: I have also found that, with 3 or more wires, sometimes the wire-nut does not screw on all the way, leaving some of the bare wire exposed. May not always be easy to see. Then, when tightening the cover, it shorts out.  $0.02