Fixed wrong storage of database key when closing preferences screen