Fix files cleanup.

Clean up routine was not waiting for parent process to exit, leading to
intermitent error when deleteing occourred before parent process releasing
files.

Also, a error handling while deleting these files was made.