A Michigan man’s last-second decision to buy a scratch-off lottery ticket as a grocery store was closing netted him a $500,000 prize, the Michigan Lottery said June 18.

The 58-year-old Wayne County resident was leaving a Kroger on West 14 Mile Road in Commerce Township when he stopped at the lottery machine to buy a few tickets.

“I was on my way out of the store because they were closing soon, and I stopped at the lottery machine to buy a few tickets before I left,” the man told lottery officials. “A worker walked up to the machine to shut it down, so I quickly bought a few tickets, scratched the barcodes, and then scanned them at the machine to check them.”

One of the tickets displayed a message directing him to file a claim. The worker told him the message meant he had won a large prize. He then used the Michigan Lottery app to scan the ticket.

“When one came back with a message to file a claim, the worker told me I must have won big, so I got out my phone and scanned it using the Michigan Lottery app,” he said. “As soon as I scanned it, she asked what was wrong because of the look on my face, so I told her I’d won $50,000. I looked down at my phone again and that’s when I realized it actually said $500,000! I had to go sit in my car and try to calm down because I was so excited and worked up that I couldn’t drive home. It was crazy.”

The winner said the prize is a “huge relief” and will allow him to clear all his debts.

“Winning $500,000 is a huge relief,” he said. “I’m going to pay off every single bill I have and then decide what to do with the rest later.”