You can either use the close() method or use a with statement to automatically close the shelf when exiting the block.