Afghan security forces have ended a siege by the Taliban group of a guesthouse attached to the Spanish embassy in Kabul, after hours of intermittent gunfire and explosions.