How to exit one day before weekly and monthly expiry

Dear Team,

I want to exit my positions one day before expiry day. For instance, if expiry day on Thursday, I want to exit my position on Wednesday and if expiry day on Wednesday, I want to exit my positions on Tuesday.

How do I achieve this?

Please advise.

Regards,
Uma

see this if helps