How do I get the ash tray to stay closed?

Buy another ash tray.
Yup, you could by another ash tray, (May be hard to find a matching color & model one for your car) of find a similar ash tray with the good spring steel scraper thingy & replace your broken one, if you're mechanically inclined & have the tools to do it.