It is well known that the normaized characters of integrable highest weight modules of given level over an affine Lie algebra $hat{frak{g}}$ span an $SL_2(mathbf{Z})$-invariant space. This result extends to admissible $hat{frak{g}}$-modules, where $frak{g}$ is a simple Lie algebra or $osp_{1|n}$. Applying the quantum Hamiltonian reduction (QHR) to admissible $hat{frak{g}}$-modules when $frak{g} =sl_2$ (resp. $=osp_{1|2}$) one obtains minimal series modules over the Virasoro (resp. $N=1$ superconformal algebras), which form modular invariant families. Another instance of modular invariance occurs for boundary level admissible modules, including when $frak{g}$ is a basic Lie superalgebra. For example, if $frak{g}=sl_{2|1}$ (resp. $=osp_{3|2}$), we thus obtain modular invariant families of $hat{frak{g}}$-modules, whose QHR produces the minimal series modules for the $N=2$ superconformal algebras (resp. a modular invariant family of $N=3$ superconformal algebra modules). However, in the case when $frak{g}$ is a basic Lie superalgebra different from a simple Lie algebra or $osp_{1|n}$, modular invariance of normalized supercharacters of admissible $hat{frak{g}}$-modules holds outside of boundary levels only after their modification in the spirit of Zwegers modification of mock theta functions. Applying the QHR, we obtain families of representations of $N=2,3,4$ and big $N=4$ superconformal algebras, whose modified (super)characters span an $SL_2(mathbf{Z})$-invariant space.