Fixed bug where inventory items were lost when closing the inventory