Casimir energy of confined massive quarks