How does options expiration work?

It depends on the option in question.

American style options are exercisable prior to expiration, exposing the seller to assignment risk. The buyer has the right to exercise at any time their options to assume possession of the underlying at a specified price (the strike price).

?A European option is exercisable only at expiration which is the following day at noon following the last trading day of the option.?

To learn more:

How to Trade Options on Expiration Day?

How to Trade Options on Expiration Day – Conclusion