Make closing the window close the processing module safely