So I was having a similar issue. Dryer would turn on but then shut off mid cycle. Brand new dryer.
With door open, I pushed the door switch all the way in and pushed the start button it comes on every time.
I realized that the door hinges were slightly bent out (display model, the door must’ve been opened too wide too often and slightly bent the hinges).
With door open, I inserted a flat head screw driver in between the hinge and where it attaches to the door, then slowly closed it enough to bend the hinges back. Works fine now.