MULE-8054: Adding check to make sure the folder is open before closing i...

...t.
The mask wouldn't work cause this is not related to a folder.