If you are on a valid H-1B, then you will be able to change status to H-4 as long as your wife's H-1B is valid and she is working for her H-1B employer. In the future, should you need to, you would be permitted to change back to an H-1B (your time spent in H-4 status won't impact the time you are allowed to be in H-1B status). You should consult with an attorney who can advise you regarding the issues to changing status and can assist you in filing the application with USCIS.
Keep in mind that once you are terminated by your employer, you no longer will have H-1B status. This may be an issue when you try to change status to H-4 because you must have status in order to change status. Except for extraordinary circumstances, late filing may not be permitted. If you are deemed to be out of status, then you will have to depart from the U.S. and seek a new H-4 visa at a U.S. consulate before you can re-enter. When you locate another H-1B job again in the future, as long as it has been six years since your visa number was counted under the H-1B Cap. Please contact a reputable law firm for further assistance (note: that most out-of-state attorneys can legally help you because we are permitted to practice federal immigration law outside of our state of jurisdiction).