Finally found the culprit of the windows crash! the plt.close() should not be there in windows at least!!!