You don't end the war, you negotiate a temporary truce. You have to take sides in the war to purchase Hjerim. Stormcloaks get it faster, from what I understand.
No, you have to pick a side and bring the war to an end. Regardless of your allegiances, the house in handed out as a 'prize' by the Jarl who rules the town when the war is over.