Stability of dissipative systems with applications to fluids and magnetofluids