Agent: try and close connection under all circumstances

Good old ```ensure```