Python POC: Added time tricks to reduce cpu use and event handlers to catch window close event