Only write BAM index once when closing

Closeable interface requires idempotency, but a BAM index is rewritten every time close() is called. This adds a check to ensure subsequent calls to close() have no effect.