In Python, How can I check and close such cmd windows like in picture? This code should control and find which cmd is finished and idle like in picture, then close i