You can't avoid paying the NIIT on Form 8960 if you have investment income (interest, dividends, rental income, capital gains) and your Modified AGI is above a certain level for your filing status. See this IRS document.
Likewise, you can't avoid paying the Additional Medicare tax on Form 8959 if your income is above a certain level for your filing status. See this IRS document.
There's no extra penalty for filing these forms.