The door switch might be loose if the microwave runs for a few seconds. Microwave running efficiently can be stopped by door switches overheating. There is a seal around the door. Microwave shuts down if the seal is broken.
Let's Get It Fixed!
HomeX virtual experts will assess your issue (for free!) and can resolve simple problems.