Fix a bug where the account was not properly saved when closing