In my python app, I print some stuff during a cycle.
After the cycle, I want to close the stdout/stderr
window that the prints produced using python code.
import sys
sys.stdout.close()
sys.stderr.close()
Might be what you want. This will certainly close stdout/stderr at any rate.