import FreeCAD as App
def close_all_docs():
#print("close_all_docs")
while len(App.listDocuments().values()) > 0:
App.closeDocument(list(App.listDocuments().values())[0].Name)