Use close instead of simply close_session in order to wait for bk termination.
All logs from failed CI contain the required log entry - "exited cleanly"
I think that the issue here is that the assert from test_api_close_session
checking for the occurrence of the sentence in the stdeer.log file is happening too fast, and bk dumps all logs after. That's why it fails.
Instead of using raw api.close_session() call, I switch it to handle.close(). It will call close_session, and waits for bk termination.