Nanopores as Switchable Gates for Nanoparticles: A Molecular Dynamics Study