Yes, it’s fine to stay at home while the door is being replaced. So, you can either stay or leave when a door replacement is being done. It is your choice. Provided the person or team working on your project is reliable, you need not to worry about leaving them at your home.
If you leave your house while the work is being done, you’ll probably be OK. It would be prudent to give the workers a little extra room to work (no one likes it when someone is standing right behind them watching), but assuming the workers are competent people, they will take appropriate precautions for your protection as well as their own. The amount of noise should be low enough that you can have a conversation with the workers if you so desire. I don’t know what sort of door you’re having replaced, but there shouldn’t be anything flying around inside the house when your door is removed.
If you stay home while the work is being done, then it’s up to you whether to choose to be near them or in another part of the house. You can even go outside if that makes you feel more comfortable and come back in when they are done. The downside of staying home is that the work area may become dusty and they might need to move some furniture out of the way (but they’d probably do that anyway). If they’re replacing an exterior door, then potentially there could be weather entering through the opening.
While you should avoid the area where work is being done, it isn’t necessary to leave the house. The fumes from a spray polyurethane foam insulation are not harmful if you are not in the same room where it’s being applied.
A good precaution would be to close all vents and doors leading to that area so that the fumes don’t spread. The only time leaving the home would be necessary is if you are chemically sensitive or have asthma.
Some people think they have to leave their homes while they’re getting door replacement because they fear for their safety. However, that’s not true. At least, not with an organized contractor or company. You don’t have to worry about leaving your home if the professional company replacing your door has a long tradition of respecting their customer’s comfort and convenience. Such a company will always make sure that their customers can go about their normal lives during their installation process.
So, yes… you can stay in your house while door replacement exercise is ongoing. A good contractor will bring all the tools and equipment needed, and they’ll do everything they can to make sure you’re comfortable while you watch them work on your new door. And don’t worry–they’ll clean up when they’re done, so you won’t even know they were there.