perf_event: Switch to internal refcount, fix race with close()