When confined photonic modes in an optical or plasmonic cavity interact strongly with a molecule, new hybrid light-matter states, termed as polaritonic states, can form. The newly formed polaritonic states are the superpositions of electrons (excitons) of the molecules and the cavity photonic modes. It was reported that these polaritons can be employed to control photochemical reactions, charge and energy transfer, and other processes. In addition, according to recent studies, vibrational strong coupling can be employed to resonantly enhance the thermally-activated chemical reactions. In this work, a theoretical model and an efficient numerical method for studying the dynamics of molecules strongly interacting with quantum light are developed based on non-adiabatic excited-state molecular dynamics. The methodology was employed to study the cis-trans photoisomerization of a realistic molecule in a cavity. Numerical simulations demonstrate that the photochemical reactions can be controlled by tuning the properties of the cavity. In the calculated example, the isomerization is suppressed when polaritonic states develop a local minimum on the lower polaritonic state. Moreover, the observed reduction of isomerization is tunable via the photon energy and lightmolecule coupling strength. These insights suggest quantum control of photochemical reactions is possible by specially designed photonic or plasmonic cavities. arXiv:1906.11210v1 [cond-mat.mes-hall]