Write context file with configure event nad cleanup.