My own personal house rule for this (and all weapons which can't be used in melee) is as follows (because my group would just keep saying "I know you can't, but what happens if I do?")
You may fire any weapon while in melee combat, but if the weapon is not a weapon which can safely be used in melee combat (so far, just Pistols), you suffer the following penalties:
-20% for shooting into melee (as you have to be careful that your opponent doesn't just grab the weapon and twist it into your gut). If you miss by less than one degree of success, you hit yourself (and obviously, your opponent has just done what I suggested). Remember the bonus for shooting at point blank range, though. Basically, you don't get a huge bonus for shooting into melee.
Your opponent gets a free attack on you, just as if you had moved away from melee without disengaging. This is simultaneous with your firing of the weapon, as you cannot kill your opponent before this attack is made, nor can he stop you from shooting.
Your weapon automatically jams after firing, as your opponent will have done anything possible to avoid being hit by it.
I know that's not totally realistic. However, it is a bit more realistic than just saying, "No matter what, you CANNOT pull the trigger on that Heavy Bolter, because the Hive Tyrant is right up in your face. You just can't bring yourself to violate proper fire discipline."
It also allows the player to make that decision, when there really isn't a better alternative (or when doing so would really be dramaticallly (or tactically appropriate). If you are definitely going to die anyway, or if you have a weapon with only one shot (or burst) left, then it might just make sense to go for it. Finally, it also prevents that annoying situation so common to flamers and other short ranged weapons, where you only get ONE shot, but if you forget to hold an action, you can't even shoot the tyranids at all, because one turn they are over 20 meters away, and the next turn, they are in melee combat. Go ahead and blast it full throttle on them as they swarm you! For the Emperor!!!