Should I payoff my debt (mortgage)

Hey, so I'm really confused with what to do so I'm turning to A71 community to get some insight. I have recently inherited a small amount of money. My question is, should I pay off my mortgage? Im still very young, 26 years old. I was debating if this is a smart move or should I just take that money and put it in stock market. My philosophy is if I pay off my mortgage I then dont have to worry about making a huge mortgage payment in the event I lose my job or if the economy goes south. Im a little ambivalent of how the stock market will perform, so I'm just curious what others' opinions are? Those with much more experience could offer some insight? Thanks!