MAINT: Move `InputRejected` to `IPython.core.error`.
BUG: Explicitly close Tee in AssertPrints and AssertNotPrints

Fixes a test failure caused by the Tee object being lazily closed only
when an AssertPrints/AssertNotPrints object is garbage collected.