The first understanding of this came from the Bohr model, where a wave closes on itself with an integral number of wave lengths in an orbit (Look it up)
Later the concept was a wave function obeying the Schrodinger equation(time independent) with correct boundary conditions. See many explanations found on the web.
Eventually solutions were found for the Hydrogen atom, or other heavier atoms, which explains a lot of Chemistry. eg. See Beiser, modern physics.