This unlock is common across both branches; pull it out in front.

Or maybe we should have the "which keepalive" logic inside the write_keepalive() function, since that has access to the features as well.