An aircraft door or window popping open in flight can be shocking and surprising, but it is usually not as big a deal as the movies and popular media would like you to believe.
The sound of an aircraft’s door or window popping open is certainly startling, and that alone can make pilots overreact with sometimes unfortunate results. The real danger from an open aircraft window or door is a pilot panicking and performing an unnecessary high-speed aborted takeoff.
If you're flying with another pilot or otherwise-capable companion, it may be possible to close the door in flight with a little aerodynamic assistance that you can muster by opening the opposite window or vent. At flying speed, the door may be impossible to close, even with that help, in which case you may opt to return to the airport, make a normal landing, and close the door. There's no rush, because everyone is wearing a seat belt, and the forces that make the door difficult to close in flight are not going to pull a person out of the airplane at low altitude.
If the door or window opens when you are at a very slow speed—such as at the beginning of your takeoff roll—you can abort the takeoff, clear the runway, and close the door.
It's worth noting that this discussion of open-door policy for pilots applies strictly to nonpressurized aircraft, which includes virtually all training aircraft. Recent events have demonstrated that a door opening at high altitude in a pressurized aircraft can become a real emergency, but let's stick to trainers: In some training aircraft, it may be possible to close a door that opens in cruise flight, or when you are in the practice area.
Are you flying a bigger, faster airplane? No worries. During my airline career, cockpit windows popped open a few times during takeoff, and we successfully got them shut and sealed without fuss or drama.
Remember, you may freak out a little bit if your airplane adopts an unexpected open-door policy, but it is usually not a big deal. There is no reason to rush—it is rushing that can cause an accident.