Hey Bunch,
The word ''stub'' means ''the usually short end remaining after something bigger has been used up.'' For example: a pencil stub; a cigarette stub.
The phrasal verb ''stub out'' means ''to extinguish some cigarette, cigar, or similar smoking material by stamping the burning end against a surface. In your example, an ashtray is the container / receptacle for the ash from smokers' cigarettes.
Here are some other examples for you:
1) ''There were no ashtrays around, so I stubbed out the cigarette on the heel of my shoe.''
2) ''If you had told me the smoke from my cigar was bothering you, I would have stubbed it out.''
3) ''He stubbed his cigar out and tossed it into the street.''
Hope that helps!!!