Hello Arif,
The reason why it doesn't work is because once the opportunity is closed, the field becomes read only. I have gotten around it by using a workflow that re-opens the opportunity, sets the field to whatever I need and then closes it again.
Does that make sense?